New to wxDev-C++ & wxWidgets: some questions Topic is solved
-
- Earned a small fee
- Posts: 15
- Joined: Thu Apr 05, 2007 11:33 am
New to wxDev-C++ & wxWidgets: some questions
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.
[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.
-
- Earned a small fee
- Posts: 15
- Joined: Thu Apr 05, 2007 11:33 am
If it helps ...
And yeah, I'm using wxDev-C++ 6.10.2 on WinXP SP2.
-
- Experienced Solver
- Posts: 66
- Joined: Thu Dec 15, 2005 8:16 pm
there is no GetHWND() function just the GetHandle() function. I copy/pasted your code into an existing project changing only the pointer name.
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.
Code: Select all
HWND MyWindow = (HWND) WxListCtrl1->GetHandle();
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.
-
- Earned a small fee
- Posts: 15
- Joined: Thu Apr 05, 2007 11:33 am
Thanks! That solves a part of my problem!
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().
HWND MyWindow = (HWND) WxListCtrl1->GetHandle();
In my code, I'd used btnLucky.GetHandle() rather than->GetHandle().
-
- Part Of The Furniture
- Posts: 1511
- Joined: Sun Jun 19, 2005 11:37 am
- Location: Singapore
- Contact:
Yes, using BASIC is an insult.
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
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
-
- Earned a small fee
- Posts: 15
- Joined: Thu Apr 05, 2007 11:33 am
Can we derive from control classes too?
First of all, Joel, I
-
- Part Of The Furniture
- Posts: 1511
- Joined: Sun Jun 19, 2005 11:37 am
- Location: Singapore
- Contact:
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
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
-
- Earned a small fee
- Posts: 15
- Joined: Thu Apr 05, 2007 11:33 am
OnLeftUP not available on wxBitmapButton Events tab
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
Oh, I
-
- Part Of The Furniture
- Posts: 1511
- Joined: Sun Jun 19, 2005 11:37 am
- Location: Singapore
- Contact:
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
The value is in screen-coordinates, so call wxPoint mousePos = myButtonOrPanelOrWhatever->ScreenToClient(wxGetMousePosition()); then call mousePos.x and mousePos.y
Joel
-
- Earned a small fee
- Posts: 15
- Joined: Thu Apr 05, 2007 11:33 am
THANKS!
This one joins all the isolated points together ! Thanks for all the help, Joel! You're very patient!