News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Custom picker control

Started by donkey, December 22, 2008, 10:03:34 AM

Previous topic - Next topic

donkey

I was thinking about using a different kind of combo box in an application I am working on and decided to try a custom control, I wrote this one over the weekend, in the end I have decided it isn't exactly what I want so I am back to the drawing board but I thought I would post it here in case anyone wants to use it as a starting point for one of theirs. It still needs work but it's functional, it could use tool tips, different image sizes etc... these are not really things I needed for my purposes so I didn't include them. Also since I abandoned the control I have not tested it except briefly on my XP system (though I am certain that it will not work on 9X systems). Anyway for what its worth here it is...

NOTE: If you expand the control post it here, I probably will not be working any further on it.

This post contains the latest version

[attachment deleted by admin]
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

#1
Being a snow day I decided to pass the time fixing some glaring errors in the control, as a bonus I added hilighting to it and a bit more parameter checking...

Whoops forgot to invalidate the drop down if no item is under the cursor when the hilight changes, there was 1 download

<bug fix - 2 DL>
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Bill Cravener

Hi Edgar, how you doing buddy?  :bg

When I run your custom control exe Task Manager shows it loads but never appears on my desktop. Task Manager says CPU usage is 50%. If I get the time I'll look thru your source and see if I can find out whats up that Vista don't like.

I'm running Vista service pk 1 on a P daul core 2.8 ghz.
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

donkey

Hi Bill,

I don't have Vista here but it may be that it doesn't like the data in the code section of PickerInit (though I can't see why), or that it coughs (like 9x) when there are more than 40 bytes of cbWndExtra memory allocated. I tried to avoid any tricky API stuff in order to have it run on different OS versions but Vista is a mystery to me. I am trying to track down the actually cause of a problem I had early on where the top of the stack in Picker_dropdown_proc would be over written but at the time I couldn't find it then the problem didn't present itself anymore, but it did lead to quite a few crashes.

<EDIT>
The problem is still there, though I masked it out and forgot about it, remove the LOCAL 'other' and put the LOCAL 'nWidth' at the top of the stack (last local entry) you will see the problem. Still no idea what causes it
</EDIT>

<EDIT>
A check of the WM_CREATE handler shows that there is a stack imbalance, there is a DWORD being pulled off the stack, I will track it down
Line 656: esp = 1241956
Line 745: esp = 1241960
</EDIT>
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Bill Cravener

Vista is a mystery to me too. I think MS had their heads up their asses when they made this one. Maybe one of the other guru's around here that run Vista will have a look. I'll look thru your source this weekend and see what it may be.
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

donkey

#5
Hi Bill, the problem was the following line in the WM_CREATE handler

invoke ReleaseDC,[hdc]

should have been

invoke ReleaseDC,[ebx+CREATESTRUCT.lpCreateParams],[hdc]

This would have resulted in the DC handle staying locked and hopefully is the reason Vista coughed...

EDIT->New upload a little further down
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

The other issue I have is not a bug but a curious aspect of the image list that I must have misunderstood. When I generate a mask for the image list I have to use a compatible bitmap, in my case 32 bit, originally I tried using a monochrome bitmap as per the documentation and it failed. I assume that when it is added to the image list the bitmap is converted to monochrome but although this is the only way to get it to work it seems to be contrary to the docs...

Quote from: PSDKThere are two types of image lists: nonmasked and masked. A nonmasked image list consists of a color bitmap that contains one or more images. A masked image list consists of two bitmaps of equal size. The first is a color bitmap that contains the images, and the second is a monochrome bitmap that contains a series of masks—one for each image in the first bitmap.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Mark Jones

I tried this Donkey, however no window was displayed from the call to DialogBoxParamA. Will have more time later to test it. XP Pro SP3.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

donkey

HI Mark,

The error code if any would be appreciated so I can track this one down. On my system it works but the only 2 responses show there is some issue with displaying the dialog, either something falls into an infinite loop or a class isn't being registered or some unanticipated error in the code. For now I have to fire up the virtual machines I guess...
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

#9
Appears to be a problem loading images from a module other than the main one. If somebody could try this on Vista...





"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Bill Cravener

You got it fixed Edgar, what was it by the way? Works perfect on Vista Home Premium. I'm still digging thru your source this weekend to have a look at what your doing.  :wink
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

donkey

Quote from: Cycle Saddles on December 23, 2008, 10:00:21 AM
You got it fixed Edgar, what was it by the way? Works perfect on Vista Home Premium. I'm still digging thru your source this weekend to have a look at what your doing.  :wink

Apparently Vista had problems with loading images from Shell32.dll directly so I put them in local resources. I will have to find a solution for the button graphic that doesn't involve the programmer having to remember to add it to the resources.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Mark Jones

The new version displays properly on my box, and seems to work ok (I can click the "V" arrow and select an icon, and its ID is reported.) However, and this may be this machine in particular, whenever I move the mouse over the text-portion of the control, all of the icons on the desktop seem to be redrawn once for each message sent. (I move the mouse into the text area, and the icons flash repeatedly for a second or two, I move again inside that area, the icons blink a few more times, etc.) It seems as though each mouse movement message is being cached in the message queue and each one causes the icons to flash.

This particular hardware has a nasty, repeatable glitch, well-known to many frustrated gamers out there. (AMD Athlon X2 4000 x64 / GeForce 8600GTS / WinXP x32, all newest drivers, etc.) Power up the system and start Windows, and during loading the desktop icons blink once or twice as they are completely redrawn (I believe this may be page faults in Explorer.exe but have no way to confirm this.) After the system is fully up and running, any DirectX/D3D/OGL game or app will run fine, as long as it remains  windowed. Switching from the desktop to any video mode, has a 50/50% chance of immediately scrambling the display and hanging the system with an nVidia "Driver in infinite loop" error, and a 95% chance of eventually causing the same over 8 hours or so. However, during normal desktop operation, opening an Explorer window and closing it will also cause the desktop icons to flash, at which point ANY graphics app started may crash the system as per above.

So, just wanted to mention that this may not be a typical behavior for your app -- but it definitely is pushing some buttons over here.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

donkey

#13
Hi Mark,

Really dumb mistake, the problem is I have RadASM in full screen and didn't notice the problem when I introduced the selection highlights. A quick fix until I rethink the selection highlights...

Moved the file to the top of the thread...
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Mark Jones

Great Edgar, that fixed it, solid as a rock now. :U
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08