There are 3 reasons why I am not sure about the control not being painted and 1 reason why it could make sense
1 because I use the now offending line in the postinit. I would say the control should have been painted in the init. I always have code in the postinit which assumes the control involved is available and this is the first time it doesn't work
2 because I have (by the way it looks) the same problem with the WebView2 content in X# and there the ghost window appears after I close the window containing the original content.
3 because when I follow Terry's suggestion to change the width, the width is changed. But the ghost window still appears. Why would the width assignment work 100% if the window/control is not shown but 1 line later the SendMessage causes a ghost window:
Code: Select all
METHOD PostInit(oWindow,iCtlID,oServer,uExtra) CLASS ComboVenster
//#s To test https://www.xsharp.eu/forum/public-vo-vn/2988-ghost-display-of-control-content-in-the-upper-left-corner-of-main-screen 2-5-2022
LOCAL oSize AS Dimension
oSize:=SELF:oDCComboBox1:Size
oSize:Width := 100
SELF:oDCComboBox1:Size:=oSize // Works, changed width is clearly visible
SendMessage(SELF:oDCComboBox1:Handle(),CB_SHOWDROPDOWN,1,0L) // Gives ghost window
RETURN NIL
4 when I move the SendMessage to a button on the screen the ghost window stays away indeed.
The earlier working method: I let the combobox inherit from Ic2ComboBox featuring these 2 methods below
Dick
METHOD FocusChange( oEvent ) CLASS Ic2ComboBox
//#s Auto drop down combobox 17-2-2004
LOCAL lGotFocus AS LOGIC
SELF:lAutoDrop:=TRUE
lGotFocus := IIF( oEvent == NULL_OBJECT, FALSE, oEvent:GotFocus )
SUPER:FocusChange( oEvent )
IF lGotFocus
IF SELF:lAutoDrop // Drop down automatically each time control receives focus
PostMessage( SELF:Handle(), CB_SHOWDROPDOWN, 1, 0L )
ENDIF
ENDIF
RETURN NIL
METHOD Dispatch (oEvent) CLASS IC2ComboboxEx
LOCAL uretval AS USUAL
uRetval := SUPER:Dispatch(oEvent)
IF oEvent:message = WM_CHAR
SELF:Setvalue(CHR(oEvent:wparam))
ENDIF
RETURN uRetval