I'd like to create a class derived from CComboBox which replaces the normal dropdown with a window containing a calendar control plus a few clickable areas. My first instinct is to create a very basic window which has the calendar as a child window and paints these clickable areas itself. When the dropdown arrow is clicked we create and show this window and somehow suppress the normal dropdown.
Is this the 'correct' way to tackle this? After trying it out I'm having a number of problems The most glaring is that when the dropdown window is displayed the frame of the hosting dialog changes, ruining the illusion that the dropdown is part of the combobox. I think this may be because the dropdown window is a WS_POPUP (to avoid being restricted to the CCombobox client area). When the dropdown is active, the dialog isn't, causing the frame to be redrawn. That's my guess anyway.
There are numerous other problems which need to be tackled: how to handle focus, mouse capture etc; how to suppress the normal dropdown list; how to handle events such as the Windows button being pressed (i.e. how to automatically cancel the dropdown). These can probably wait for now though
Anyone have any solid suggestions about how to create this custom dropdown? Any good links, blogs, books, or articles?
Nice article, but it doesn't address the specific problem I described. I ran your demo app and sure enough the frame of the dialog changes to reflect that it is no longer active or has focus, or whatever the change of frame painting means . Compare this to the Date Time Picker control (which is loosely what I'm trying to mimic): when its dropdown window is shown it doesn't cause any change to the dialog, and feels integrated with the rest of the control. It's a minor detail, but it's one which makes me think my basic approach is wrong somehow.
After some playing around it seems as though setting the focus is what triggers the repainting of the dialog's frame. If the dropdown is created as a child (of the combobox), it doesn't redraw to show loss of focus. But the dropdown can't be a child due to clipping. If it's a popup then it causes the frame to be painted differently when the focus switches, which is what I was hoping to avoid.
Catch 22 for the time being. But this must be a very solveable problem...
Where does the focus go then? I guess you are not moving the focus to your popup ...umm... "explicitly". Maybe try removing the WS_TABSTOP style from controls on the popped-up window or somesuch... is your popup maybe a dialog? If yes then it probably places the focus onto whatever comes first on it that can receive the focus automatically, you can avoid that by returning FALSE from OnInitDialog[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
I'm currently capturing screenshots and I want to save the images as files..
did manage to do it, but in .bmp format
I would like to know if there is a method to directly save the image as .jpg OR is there a possibility of converting the .bmp file to .jpg
Long story, this isnt the exact use case but its a representation of the problem im having.
Lets say i then call a function that takes a Char*, i pass into this function "Hello!", upon arriving at this function the pointer lets say points to 0x55 containing "Hello!", this function then does bit manipulation on the Char*, so it now says "!olleH" at location 0x55
Now I again pass "Hello!" into the same function that takes a Char*, it goes directly to 0x55 and does the exact same bit manipulation, UNDOING the "encoding" and bringing the text back to "Hello!" rather than actually passing in a new instance of "Hello!" that i passed into it and encoding it to "!olleH" as it should.
Its as if the compiler is optimizing and any time it see's "Hello!" being passed through this function to just go straight to that memory location not knowing ive done bitwise things too it.
How do i stop this from happening or how can i trick the compiler into stopping this?
If i sprintf "Hello!" into a temporary buffer, and then print that, it works fine. But thats not a solution I can use unfortunately as there are hundreds if not thousands of lines that print "Hello!".
During my bitwise manipulation i've tried to create a new char, copy my text over to it, bit manipulate the new char, and then copy it back. But no luck, it just seems to point to that same location when i call the function.
how about you post the smallest fragment(s)/part(s) of code that demonstrate the issue - its a bit hard without seeing the function def, how you're calling it etc etc - please use the [code block] pre & /pre xml around your code as well
While doing this i have WinDbg open and look at the pointer location for Input, lets say its x00500, you can see all 5 characters in Hello and their hex codes in Byte view.
Swapbits reverses the hi 4 bits for the low 4 bits in each UINT8 byte put in. It does this through a lot of bit manipulation, i dont have the code available now but it doesnt matter its not pertinent really. So instead of having a Hex of 0x25 fed in, it outputs 0x52. Sort of a ghetto encryption method.
All good so far.
Now call this again...
if you look at the pointer it uses it does NOT create a new char* pointer. Instead it points to the one it made the first time at 0x500(still encrypted). Obviously passing in the bit swapped value just bit swaps it back. So swapbits outputs 0x25, from the previous example.
Every time you call Send("Hello", 0) it will point to 0x500 not knowing its been manipulated. It has to be some compiler thing trying to optimize these strings used multiple times only delcaring them in memory once, but its breaking everything.
Ok, I think the problem you're having is how the compiler handles string literals by default. Every sting constant such as your "Hello!" has to be stored in your .exe file. By default, I think, VC++ combines indentical string literals into one instance to save space. Most of the time, these are put into programs to be treated as constants. In your case, you're saying it's ok to modify the memory locations that hold "Hello!". Since the compiler combines all instances of "Hello!" into one, all pointers to it will point to the same block of memory. Change that memory and it's changed for all instances.
I think there's a compiler or linker flag to force code generation to not combine string literals but I couldn't find it when I looked. Maybe they did away with it since the last version I saw that had it and now you're stuck with what you're seeing.
One way around it would be to define "Hello!" once and copy it to a separate buffer each time you want to play with it.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.