goldy1064
3rd August 2005 23:38 UTC
Custom page with a bitmap link
I have a custom page and am trying to make one of the Bitmaps into a link. This has not worked with the IOEx the way it is (either only the link is above the bitmap, in which case the bitmap is hidden, or the bitmap is above the link and the link doesn't work). Because of this, I've went in to the IOEx code and been playing around. Right now, I've added a new flag to Bitmap called IMAGELINK that will change the cursor to a hand when it is over the image. I took a little pointer from this thread. This is what I've got:
CreateWindowEx(...
...
case FIELD_BITMAP:
...
if (pField->nFlags & FLAG_IMAGELINK)
{
SetWindowLong(pField->hwnd,GWL_STYLE,GetWindowLong(pField->hwnd,GWL_STYLE)|SS_NOTIFY);
SetClassLong(pField->hwnd,GCL_HCURSOR,(long)LoadCursor(NULL,MAKEINTRESOURCE(32649)));
}
...
The problem is that this is setting the cursor for the entire class type, which are mostly STATIC (I have one DropList), so every label, image, etc. that uses this class type has the cursor changed to a hand. Is there any way to only change it for those images I want using this flag? Would it be better to make a new type and then have a Callback Proc like the link field does?
Thanks in advance!
goldy1064
4th August 2005 01:53 UTC
Well, I seem to be extremely good at figuring out my problems after asking for help...
Anyways, I was able to fix this by creating a new flag FLAG_IMAGELINK. I then added the following in IOEx to get the Bitmap to have the hand over it.
...
if ( pField->nFlags & FLAG_IMAGELINK ) pField->nParentIdx = SetWindowLong(hwCtrl,GWL_WNDPROC,(long)StaticIMAGELINKWindowProc);
int WINAPI StaticIMAGELINKWindowProc(HWND hWin, UINT uMsg, LPARAM wParam, WPARAM lParam)
{
int StaticField = FindControlIdx(GetDlgCtrlID(hWin));
if (StaticField < 0)
return 0;
FieldType *pField = pFields + StaticField;
switch(uMsg)
{
case WM_NCHITTEST:
break;
/*case WM_PAINT:
break;*/
case WM_GETDLGCODE:
break;
case WM_SETCURSOR:
{
if ((HWND)wParam == hWin && LOWORD(lParam) == HTCLIENT)
{
HCURSOR hCur = LoadCursor(NULL, IDC_HAND);
if (hCur)
{
SetCursor(hCur);
return 1; // halt further processing
}
}
}
}
return CallWindowProc((WNDPROC)pField->nParentIdx, hWin, uMsg, wParam, lParam);
}
That's at the end of the case FIELD_BITMAP from above.
Second question: How should I edit the message WM_NCHITTEST in order to get clicking to only work after the left click has been released and not when it's pressed down?
deguix
4th August 2005 10:42 UTC
I did put the feature on the latest version launched yesterday. I added a new value name for "Field #" INI sections called NotifyIcon. With this, you can change the cursor of the mouse when it's over a control which has the "ONCLICK" notification flag.