New to wxDev-C++ & wxWidgets: some questions Topic is solved

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
srikant1987
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Apr 05, 2007 11:33 am

New to wxDev-C++ & wxWidgets: some questions

Post by srikant1987 »

Well, I have a lot of questions to ask of you all, but I'll ask them at a reasonable speed.

[I'm using wxDev-C++ 6.10.2.]

1. For those of you who know some Visual Basic (would this be insulting?), which control would be most like the PictureBox? Actually, I want to be able to draw on it (using methods like DrawLine), and to capture MouseUP's on it (along with where on the control they occur).

2. I'm not able to use this GetHandle() function to get the hWnd of a control properly. (And is there a function called GetHWND() too?) If I write

HWND * MyWindow = (HWND *) btnLucky.GetHandle();

I get "primitive-expression" required before '*' token, and if I write

HWND MyWindow = (HWND) btnLucky.GetHandle();

I get primitive-expression required before ')' token. (I'm not sure "required" is the word in the exact error.)

3. I think that should be enough for now.
srikant1987
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Apr 05, 2007 11:33 am

If it helps ...

Post by srikant1987 »

And yeah, I'm using wxDev-C++ 6.10.2 on WinXP SP2.
spedgenius
Experienced Solver
Experienced Solver
Posts: 66
Joined: Thu Dec 15, 2005 8:16 pm

Post by spedgenius »

there is no GetHWND() function just the GetHandle() function. I copy/pasted your code into an existing project changing only the pointer name.

Code: Select all

HWND MyWindow = (HWND) WxListCtrl1->GetHandle();
it compiled perfectly fine.
make sure you dont have any missing/extra braces or brackets any where .

I cant help with the BASIC part though. But if you want the functionality of drawing you could use a wxClientDC to draw to a wxPanel. the wxPanel is capable of handling the mouse events. you would need to override the wxpanel event handeling though. there is a wxStaticBitmap but that is only meant for small bitmap such as icons.
srikant1987
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Apr 05, 2007 11:33 am

Thanks! That solves a part of my problem!

Post by srikant1987 »

The exact line of the command gives information rather effectively, doesn't it?

HWND MyWindow = (HWND) WxListCtrl1->GetHandle();

In my code, I'd used btnLucky.GetHandle() rather than->GetHandle().
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

Yes, using BASIC is an insult. :P

The first problem I see is that unlike VB (which I had like a pathetic exposure to after pretty much mastering C++) C++ has a difference between the . and the -> operator. -> is for pointers, . is for references and values.

In this case, btnLucky is a pointer, so you use HWND * MyWindow = (HWND *) btnLucky->GetHandle();

IIRC GetHandle is a protected function, so use HWND * MyWindow = (HWND *) btnLucky->GetHWND();

Third, HWND is actually a typedef (you know what a typedef is? I hope you do.) to a void*. So, HWND* is actually void**. There's no need for a pointer-to-pointer (and since GetHWND returns a HWND you don't need the extra *). So HWND MyWindow = btnLucky->GetHWND(); should work.

Yes. You can use a wxPanel to draw on it and stuff, or if you really just want to have a bitmap use wxStaticBitmap.

Joel
srikant1987
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Apr 05, 2007 11:33 am

Can we derive from control classes too?

Post by srikant1987 »

First of all, Joel, I
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

When you go to the Events tab of the wxBitmapButton, Click on the Drop-down menu and select Add New Function and add your code there. There's no need to inherit from wxBitmapButton. We only inherit wx classes for top-level windows and other "reusable" components (compound controls etc).

The & means its a reference and not a pointer. References are identical to pointers (at the assembly code level) but is easier for the compiler to optimize (because there are lesser assumptions to make.) Don't ask why, it'll be an essay in itself, lol.

Joel
srikant1987
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Apr 05, 2007 11:33 am

OnLeftUP not available on wxBitmapButton Events tab

Post by srikant1987 »

When you go to the Events tab of the wxBitmapButton, Click on the Drop-down menu and select Add New Function and add your code there. There's no need to inherit from wxBitmapButton. We only inherit wx classes for top-level windows and other "reusable" components (compound controls etc).
Oh, I
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

There's no issue if you need to know where the mouse is. Use wxGetMousePosition(). It returns a wxPoint (so use the .x and .y members).

The value is in screen-coordinates, so call wxPoint mousePos = myButtonOrPanelOrWhatever->ScreenToClient(wxGetMousePosition()); then call mousePos.x and mousePos.y

Joel
srikant1987
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Apr 05, 2007 11:33 am

THANKS!

Post by srikant1987 »

This one joins all the isolated points together :idea: ! Thanks for all the help, Joel! You're very patient!
Post Reply