-
anyway, I put below in .h file (not sure it's correct or not)
#ifndef GWLP_WNDPROC
#define GWLP_WNDPROC GWL_WNDPROC
#endif
After compilation, I still can't get mouseover works after integrate your code in.
RussG1,
to answer your question, I'm doing this for multiple buttons. each button will have highlight state and normal state ( each button will have two bitmap - highlight bitmap and normal bitmap)
Can you post a sample project file with your code below ?
Regards.
-
anyway, I put below in .h file (not sure it's correct or not)
#ifndef GWLP_WNDPROC
#define GWLP_WNDPROC GWL_WNDPROC
#endif
After compilation, I still can't get mouseover works after integrate your code in.
RussG1,
to answer your question, I'm doing this for multiple buttons. each button will have highlight state and normal state ( each button will have two bitmap - highlight bitmap and normal bitmap)
Can you post a sample project file with your code below ?
Regards.
-
Put the defines in the .h file at the top, before you include windows.h like this.
#define _WIN32_WINNT 0x0400
#define WINVER 0x0500
#define WIN32_LEAN_AND_MEAN
#define STRICT
#include <windows.h>
#include "resource.h"
, etc.
As for GWLP_WNDPROC, I apologize, that should be GWL_WNDPROC. GWLP_WNDPROC is used with SetWindowLongPtr (although GWLP_WNDPROC should work, as it has same definition (and it worked when I tried it). I am not sure why it is not defined for you, maybe you do not have latest Platform SDK?).
As for a sample, I just added that code to the sample I attached previously and it worked. Give me a sec and I will attach the modifed example (I was testing some other things in that sample, so I need to clean out the extra stuff...).
*edit *
putting the defines for the windows version, etc. in stdafx.h is fine as well (I missed that part of your post)
-
1 Attachment(s)
OK, here is the modified sample.
The bitmaps are nothing fancy, I just used the bitmap editor is VS to create basic bitmaps for example, everything else should be same as it was previously.
Let me know if you have any problems with it.
** edit ***
Modified sample per request below.
-
Instead of loading bitmap, if I create picture in the Main Dialog with IDC_Normal, IDC_Normal will point to/use IDB_BMP_NORMAL ? how can I use IDC, instead of IDB.
Same for IDB_BMP_HIGHLIGHT, I also use IDC_Highlight
-
The resource name is just a name, it can be whatever you want (IDB_NORMAL, IDC_NORMAL, XXX_NORMAL, XXX_XXXXX, XXXXXX etc, whatever you want).
What do you mean by "create picture in the Main Dialog" as opposed to loading the bitmap from a resource?
How are you creating the picture?
***edit***
Open up resource.h and sample.rc in a text editor and you will see how the bitmaps are defined and the filenames that they point to. You can change the resource names for the bitmaps to whatever you want, just make sure that they match in the .rc file, the resource.h file, and in the LoadBitmap function (or whatever method you are using to load your bitmaps).
-
I understand what U mean.
What I meant is in the Dialog,
I insert a picture, set the ID to be ...let say IDC_NORMAL, under picture properties it use Type BITMAP, Image IDB_BMP_NORMAL
then I Insert another picture into the Dialog, set the ID to be IDC_HIGHLIGHT, under picture properties, it use Type Bitmap, Image IDB_BMP_HIGHLIGHT
So, now I have IDC_NORMAL and IDC_HIGHLIGHT instead of using LoadBitmap IDB_BMP_NORMAL and IDB_BMP_HIGHLIGHT.
-
I am not sure I understand completely.
Do you mean you insert a Picture Control into the dialog (a picture control is nothing more than a static control that displays a picture (when set to type bitmap)). It is not the picture itself, thus cannot be used as an image for a button. You would have to get the handle of the bitmap that is displayed by the picture control and then use that handle in your BM_SETIMAGE message to use that bitmap on your button. (a picture control is meant to show a picture, and not to be used as an imagelist, etc, if you are not using it to show a picture on the dialog, you are better off just doing as I did, and insert a bitmap resouce into the project rather than using a picture control).
-
BTW: If there is some reason why you need to use the picture control this way, you can send the STM_GETIMAGE message to the Picture Control, to retrieve the handle of the bitmap, and then you should be able to use that handle (store it in a global HBITMAP variable) in your BM_SETIMAGE message.
-
okie..I use bitmap instead. I tried and the method is ok. But the problem is the bitmap can not display properly.
Note: all my bitmap contains more than 256 colors. it cannot load in the bitmap editor.
How can I fix that ?
-
ok, if I use STM_GETIMAGE, what are the changes in your sample project ? I'm trying with no luck.
Maybe can you create two picture controls (IDC_NORMAL) and (IDC_HIGHLIGHT) and resend me the sample? Thanks a lot.
-
I am not sure why the VS editor will not let you edit some bitmaps, as you can create True Color bitmaps, in the editor by clicking the "Colors" listbox and changing it to True Color. I am not sure of any fix for this, but you can still use the bitmaps, you just cannot edit them in the VS editor (at least I don;t know of any way to do it)
As for your bitmaps not displaying properly, I am not sure, but you may want to use LoadImage rather than LoadBitmap, as LoadBitmap creates a new bitmap that is compatible with the display (thus the bitmap may be modified).
-
To modfiy the code to use STM_GETIMAGE, you need only change the following.
Remove or comment out the LoadBitmap lines in WM_INITDIALOG and replace with the following:
PHP Code:
// get HWND's for the picture controls
HWND hWndStatic1 = GetDlgItem(hMain, IDC_STATIC1);
HWND hWndStatic2 = GetDlgItem(hMain, IDC_STATIC2);
// get handle to bitmaps from picture controls
hBmpNormal = (HBITMAP)SendMessage(hWndStatic1,
STM_GETIMAGE, IMAGE_BITMAP, 0);
hBmpHiLight = (HBITMAP)SendMessage(hWndStatic2,
STM_GETIMAGE, IMAGE_BITMAP, 0);
The rest of the code should be the same.
-
RussG1, I tried your STM_GETIMAGE with no success. The bitmap picture can not be loaded properly. The mouseover action seems ok.
-
Whenever I mouseover, it will change to Grey color, instead of display my picture control bitmap.