I've seen this recently as well, as far as I know for the first time and now I got it again. I have a DataDialog with a comboboxEx on it. I wanted it to drop down on opening the window for which I already created some code which I didn't immediately realize. Anyhow, I found this line and put it in the PostInit:
What happens is that the content which should be displayed within the dropped down combobox displays as a kind of ghost image in the upper left corner of my main screen. See image, I added SomeName twice for this picture and put the real window next to the "ghost content' but if the real window opens in another monitor the 'ghost' window is still in the main monitor. As soon as I click somewhere in the screen, or issue a Setfocus or something, the "ghost window" disappears (and the window with the combobox opens normally.
I can't be sure, but it looks to me as though, by putting that line in the PostInit you have shifted the display co-ordinates.
My reason for saying this is that the x,y co-ordinates relate to your screen (in pixels). What you see on screen
will always be related to the
Top Left screen co-ordinates, (0,0).
By including that line in the PostInit you are adding the combo box, then telling the DataDialog to manifest itself
1 unit right of 0, and 0 down. (The unit is probably pixels. Can't be sure about this, but in any event it is NOT 0,0 where it should be.
So the problem is not showing a ghost, but not overwriting the entirety of a control.
I hope this makes some sense. I know it's a bit of a brain teaser.
You could just check if what I am saying is correct by changing the line to:
SendMessage(SELF:oDCcBox:Handle(),CB_SHOOWDROPDOWN, 0, 0L)
Thanks for your replies. I first tried to change wParam of SendMessage from 1 to 0. This resulted in the combobox no longer expanding at all. And I think I have not much other choices than to put in the postinit (as written, I have another solution which works).
Then I added a DataDialog with a combobox to a simple test app and indeed, the ghost window appears there too.
I will send it to Chris to see if we can find the cause. I have the same issue in an X# solution where I show a WebView2 in a Custom control so if Chris can find out what happens it will probably solve that issue too.
I am a bit puzzled as to why you do things this way. If the control is intended to be on the Dialog it should be initialised within the window itself. i.e its Init method. Correct ordering follow automatically and the offending line would not be required.
Maybe I'm misunderstanding something.
I emphasize that I later found a solution created earlier which actually works. So getting it to work is not the real issue.
I am however puzzled while this line of code has such a weird effect, as I found this in the comp.lang NG as a way to just auto-expand the combobox. The way I see it is that the comobox is already initialized in the init and hence the SendMessage should do just that job when issues in the postinit. I also wonder what actually happens as the system is painting outside the control and I have another such situation in a completely different situation in an X# program.
As this is probably easy to follow for an expert like Chris, I sent him that basic sample and I will certainly report back his findings. And hopefully it helps me solve the X# issue as well.
Nobody is more of an expert in this area than Karl-Heinz!
I agree with what the other guys said, it's a problem of trying to drop down the combo box, before it is shown.and windows receives a message at a time it does not expect it to, and gives this weird, semi-random behavior. I think this specific behavior has to do with the implementation details of the control, as I assume the drop down part of the combobox is implemented as a separate window which is disaplayed by windows on top of the owner window of the control, but then you try to show this before the owner window is shown and all hell breaks lose..
You definitely need to do this after the window is being shown, but not sure exactly when is the right time. Before looking further into it, you said you have already found a solution. Which is that?