en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en nl en en en en de en en en en en nl en en en en en en en sk en en en en en en fr en da en en en en en en en nl en en en en en en en en en en en en en en nl en en en en en en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in PowerBASIC for Windows only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
ownerdraw button icon detect selected
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
Join Date: Aug 2005
ownerdraw button icon detect selected
17 Oct 2008, 06:04 AM
How can I detect that the left mouse button is pressed when over an ownerdrawn button, so as to change the icon? Tried DRAWITEMSTRUCT.itemaction = ODA_SELECT and DRAWITEMSTRUCT.itemstate = ODS_SELECTED without luck. Or is it necessary to do it under WM_LBUTTONDOWN?
Join Date: Aug 1998
17 Oct 2008, 08:15 AM
How can I detect that the left mouse button is pressed when over an ownerdrawn button
"Pressed" as in the mouse had been captured and is in a drag operation, or "clicked" as in "depressed when located over the control?"
If the latter, you should get a WM_COMMAND/BN_CLICK notification... but I think you should also be getting a WM_DRAWITEM at that time.
But if you are getting WM_DRAWITEM, you can use GetCursorPos() to find the mouse position. I can't find a function like GetKeyState for the mouse ("is mouse button down?") but I have to believe there is one, so then you would know where the mouse is and if it's depressed on each WM_DRAWITEM and draw accordingly.
Or maybe you can hot-track it so in your DRAWITEMSTRUCT you can query:
Windows 98/Me, Windows 2000/XP: The item is being hot-tracked, that is, the item will be highlighted when the mouse is on the item
(Nope I don't know how to hot-track a button; or even that it's doable. It's a thought).
There's also a bunch of other mouse functions which might be handy eg getMouseMovePointsEx, TrackMouseEvent.
Port Washington WI USA
Join Date: Aug 2005
17 Oct 2008, 08:52 AM
Well I had the right conditions after all, but was confusing myself nicely by using a transparent icon.
Here is some code which works with PBWin v9 (and probably v8 too). It includes BINBAS statements to put the icons into code, rather than using a resource file or loading icons from disc. But you ignore all that stuff and load the icon any way you want to, the WM_DRAWITEM handler will be the same -unless you can improve on it, which would be even better!
Just don't mention the icon quality.
' ' DDT example using an icon on an ownerdrawn button. ' no image files, no resource! ' Chris Holbrook Oct 2008 ' ' uses Edwin Knoppert's BINBAS to store the images in code ' you can download it from http://www.hellobasic.com/download.aspx ' see examples in PowerBASIC source code forum ' #COMPILE EXE #DIM ALL #INCLUDE "WIN32API.INC" %IDC_DONE_BN = 1001 %IDC_LABEL1 = 1002 '--------------------------------------------------------------- '////////////////////////////////////////////////////////////////////////// '// Icon loading '////////////////////////////////////////////////////////////////////////// TYPE TAGICONDIR idReserved AS WORD '// Reserved (must be 0) idType AS WORD '// Resource Type (1 For icons) idCount AS WORD '// How many images? END TYPE TYPE TAGICONDIRENTRY bWidth AS BYTE '// Width, In Pixels, of the Image bHeight AS BYTE '// Height, In Pixels, of the Image bColorCount AS BYTE '// Number of colors In Image (0 If >=8bpp) bReserved AS BYTE '// Reserved ( must be 0) wPlanes AS WORD '// Color Planes wBitCount AS WORD '// Bits per pixel dwBytesInRes AS DWORD '// How many bytes In this resource? dwImageOffset AS DWORD '// Where In the file is this image? END TYPE '// Creates an icon using plain filedata, like the 766 Bytes .ICO files. '// Returns a iconhandle. FUNCTION SetIconFileBits( BYVAL lpMem AS LONG ) AS LONG DIM pIconDir AS TAGICONDIR PTR DIM IconDirEntry AS TAGICONDIRENTRY PTR pIconDir = lpMem IF @pIconDir.idCount   %IDC_DONE_BN THEN EXIT SELECT IF (@pDIS.itemaction = %ODA_SELECT) AND (@pDIS.itemstate AND %ODS_SELECTED) THEN DrawIconEx @pDIS.hDc, 0 , 0, hIconSelected, 16, 16, 0, 0, %DI_NORMAL ELSE DrawIconEx @pDIS.hDc, 0 , 0, hIconNormal, 16, 16, 0, 0, %DI_NORMAL END IF CASE %WM_COMMAND IF CBCTL = %IDC_DONE_BN THEN DIALOG END CBHNDL, 0 END SELECT END FUNCTION '---------------------------------------------------------------------------- FUNCTION PBMAIN () AS LONG LOCAL hdlg AS DWORD DIALOG NEW 0, "test ownerdrawn button with icon", 0, 0, 150, 50 TO hdlg CONTROL ADD BUTTON, hdlg, %IDC_DONE_BN, "",20, 20, 12, 12, %BS_OWNERDRAW OR %WS_CHILD CONTROL ADD LABEL, hdlg, %IDC_LABEL1, "CLOSE", 35, 20, 30, 12 DIALOG SHOW MODAL hdlg CALL cb END FUNCTION
Join Date: Aug 2005
17 Oct 2008, 08:59 AM
Originally posted by Michael Mattias View Post
If the latter, you should get a WM_COMMAND/BN_CLICK notification... but I think you should also be getting a WM_DRAWITEM at that time.
Yes, it's all got to happen in WM_DRAWITEM, else you need other events both to detect the click and loss of focus, etc. I think I will leave hottracking for another day when I am feeling stronger. That hot-tracking presumably is what b*ggers up the displaying of spindly transparent icons on XP.
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 04:53 AM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.