The MASM Forum

General => The Campus => Topic started by: asmcoder on December 27, 2013, 12:04:51 PM

Title: how to draw checkboxs in a combobox
Post by: asmcoder on December 27, 2013, 12:04:51 PM
(http://bwpkb.img38.wal8.com/img38/397073_20131226203745/138810569724.jpg)

hi all,
as you see in the picture, there are 15 checkboxs in a combobox.
when selected multiple items, all the selected index(or text) will show in the text area of the combobox
how to do this? any example?
Title: Re: how to draw checkboxs in a combobox
Post by: dedndave on December 27, 2013, 01:18:03 PM
if i was just starting out, i would do it this way....

write a simple program with just a combo box
learn how to place and retrieve text in the edit control
learn how to place text in the drop-down

make another simple program with just check boxes (which are actually a button style)
learn how to put text on them
learn how the mouse events to check/uncheck the boxes send messages to the application

then - write the program with both
Title: Re: how to draw checkboxs in a combobox
Post by: asmcoder on December 27, 2013, 01:28:58 PM
hi dedndave,
i think the difficult part is handle WM_DRAWITEM message and create a number of checkboxes
Title: Re: how to draw checkboxs in a combobox
Post by: dedndave on December 27, 2013, 02:09:57 PM
that should only be required for an owner-drawn box

http://msdn.microsoft.com/en-us/library/windows/desktop/bb775792%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb775792%28v=vs.85%29.aspx)
Title: Re: how to draw checkboxs in a combobox
Post by: dedndave on December 27, 2013, 02:13:44 PM
\Masm32\Examples\dialogs_later\lists
\Masm32\Examples\exampl04\jacts

i would post an example, but the one i have - the combobox us subclassed
that would just make things difficult for a beginner   :P
Title: Re: how to draw checkboxs in a combobox
Post by: asmcoder on December 27, 2013, 06:00:05 PM
i used olly reversed the software, found the author did not create checkbox.
he used CopyRect to draw the check/uncheck rectangle
used GetSysColor、SetBkColor、SetTextColor、ExtTextOut、TextOut to handle WM_DRAWITEM

so the problems left are multiple check and set the edit text in combobox, because when clicked a item, the dropdown list will be invisible.

Title: Re: how to draw checkboxs in a combobox
Post by: sinsi on December 27, 2013, 06:17:50 PM
Have a look at the latest Event Viewer filter dialog to see why a combobox with checkboxes is a bad idea. You actually have to click off the combobox to close it.
Haven't listboxes got a checkbox style? Much better for the user, an edit and a listbox.
Title: Re: how to draw checkboxs in a combobox
Post by: asmcoder on December 27, 2013, 06:37:01 PM
Quote from: sinsi on December 27, 2013, 06:17:50 PM
Have a look at the latest Event Viewer filter dialog to see why a combobox with checkboxes is a bad idea. You actually have to click off the combobox to close it.
Haven't listboxes got a checkbox style? Much better for the user, an edit and a listbox.

hi sinsi,
i just want to improve my coding skill .
i didn't know how to deal with OwnerDraw contorls, i think it's the same to all beginners
when i see the "magic" control, i have a strong desire to figure out how it works.
now i know there are NO real checkboxes , so i think the fake checkboxes in a combobox is not a bad idea
when i figure all things out , i will show my code.
Title: Re: how to draw checkboxs in a combobox
Post by: ragdog on December 27, 2013, 07:50:41 PM
Hey

Here is a good Ownerdraw Listbox example with checkboxes
A Listbox is similar to Combobox you must replace the windows Messages

Example
LB_SETITEMDATA to CB_SETITEMDATA
...
..

And Test it

http://www.masmforum.com/archive2012/8260_ODListBox.zip

or look in radasm source addin Manager
Title: Re: how to draw checkboxs in a combobox
Post by: asmcoder on December 27, 2013, 08:17:46 PM
Quote from: ragdog on December 27, 2013, 07:50:41 PM
Hey

Here is a good Ownerdraw Listbox example with checkboxes
A Listbox is similar to Combobox you must replace the windows Messages

Example
LB_SETITEMDATA to CB_SETITEMDATA
...
..

And Test it

http://www.masmforum.com/archive2012/8260_ODListBox.zip

or look in radasm source addin Manager

wow, this is exactly what i want. thank you ragdog
Title: Re: how to draw checkboxs in a combobox
Post by: ragdog on December 27, 2013, 08:26:19 PM
Exactly what you want?

i have think you want it for a combobox?

Ok is not difficult to change it for a Cbo
Title: Re: how to draw checkboxs in a combobox
Post by: asmcoder on December 27, 2013, 08:58:16 PM
Quote from: ragdog on December 27, 2013, 08:26:19 PM
Exactly what you want?

i have think you want it for a combobox?

Ok is not difficult to change it for a Cbo

i mean the method. yes i need to do some changes.
Title: Re: how to draw checkboxs in a combobox
Post by: dedndave on December 28, 2013, 01:52:12 AM
the fact that the original program used rectangles to draw checkboxes is ok
but - that's somewhat of an advanced technique

for a beginner, just use buttons with the proper style bits
Title: Re: how to draw checkboxs in a combobox
Post by: ragdog on December 28, 2013, 05:17:32 AM
Right dave
But is easy to understand i have a other from Ernest Murphy && NaN
but is better only not easy to understand
Title: Re: how to draw checkboxs in a combobox
Post by: asmcoder on December 28, 2013, 10:01:03 AM
hi all,
i have done the job ! :biggrin:
please have a look at my code.

(http://bwpkb.img38.wal8.com/img38/397073_20131226203745/138818631518.jpg)
Title: Re: how to draw checkboxs in a combobox
Post by: qWord on December 28, 2013, 12:11:39 PM
ESI, EDI and EBX are nonvolatile registers and must preserved by call-back functions (e.g. Dlg/WndProc)