Forum | | | |  Ernst | Hello - ask, ask, and over again ask .....
The first: if I the Edit einfärbe with profanem Subclassing, becomes with Closing the Mainwindow the Edit entfärbt (code1); with usage of nproc (code2) remaining the Edit until end colored. Why goes The colour flöten - mach I what wrong ? 
code1:
$H windows.ph
$H messages.ph
Declare brush&, dlg&, edit&
usermessages 16
set("FASTMODE",1)
Window Style 26
Window 100,100-500,300
CLS RGB(212,208,200)
dlg& = Control("DIALOG","",$54000000,50,200,200,20,%hwnd,0,%hinstance,0)
edit& = Create("EDIT",dlg&,"",0,0,width(dlg&),height(dlg&))
setfocus(edit&)
subclass dlg&, 1
While 1
Waitinput
IF %Umessage = 16
MessageBox("","",0)
break
endif
EndWhile
subclass dlg&, 0
deleteobject brush&
End
' ----------------------------------------------------------------------------
SubClassProc
If SubClassMessage(dlg&, ~WM_CTLCOLOREDIT)
IF Brush&
DeleteObject Brush&
EndIf
Brush& = ~CreateSolidBrush(RGB(255,255,170))
~SetBkMode(&swParam, ~TRANSPARENT)
~SetTextColor(&swParam,RGB(0,0,255))
set("winproc",0)
Return Brush&
EndIf
ENDPROC
code2:
{$iq}
$H windows.ph
$H messages.ph
Declare brush&, dlg&, edit&, dlg_opc&
usermessages 16
set("FASTMODE",1)
Window Style 26
Window 100,100-500,300
CLS RGB(212,208,200)
dlg& = Control("DIALOG","",$54000000,50,200,200,20,%hwnd,0,%hinstance,0)
edit& = Create("EDIT",dlg&,"",0,0,width(dlg&),height(dlg&))
setfocus(edit&)
dlg_opc& = ~SetWindowLong(dlg&,~GWL_WNDPROC, ProcAddr(dlg_CP,4))
setfocus(edit&)
While 1
Waitinput
IF %Umessage = 16
MessageBox("","",0)
break
endif
EndWhile
deleteobject brush&
End
' *******************************************************************************************************************
nProc dlg_CP
parameters wnd&, msg&, wp&, lp&
global dlg_opc&, brush&
IF brush&
~DeleteObject(brush&)
Endif
If msg& = ~WM_CTLCOLOREDIT
brush& = ~CreateSolidBrush(RGB(255,255,170))
~SetBkMode(wp&, ~TRANSPARENT)
~SetTextColor(wp&,RGB(0,0,255))
Return brush&
EndIf
Return ~CallWindowProc(dlg_opc&, wnd&, msg&, wp&, lp&)
Endproc
|
| | | | |
| |  | because The SubClassProc in the comparison to nProc only WaitInput called becomes, instead of with alike welchem Programmteil. differently said with nProcs 1:1/ verlustfreies native SubClassing and the SubClassProc Interpreter-SubClassing. so has one ever to task The electoral the geeigneteren Through.
hint: with nProc will need you none Fastmode. |
| | | | |
| |  Ernst |
hint: with nProc will need you none Fastmode. once I Fastmode entferne, appear the Edit first of all with weißem background and becomes first to the first Tastendruck or. Mausclick in the Window-Client-area colored. remedy : then appear the Edit immediate eingefärbt - or there a elegantere Solution? |
| | | | |
| |  | the behaviour is nachvollziehbar, there You, the Control first erstellst with of/ one normalen wProc of XProfan - The The "weiß" draw - and thereafter first a abweichende wProc for the Control festlegst but the new wProc without invitation for Repaint first naturally too not at all called becomes. usually would (same) one at create the Controls (z.B. by createWindowEx-function) The "abweichende" wProc indicate. here must You now then to the determine the new wProc the control first to that Repaint moving or. to that trigger off the WM_CTLCOLOREDIT Message. Try to the gwl_wndProc means time something like How RedrawWindow(lever,0,0,0). The Mallet this would showwindow lever 0 and subsequently schowwindow lever 1. You can also first any Controls create and new gwl_wndprocs settle and thereafter the whole Window to that Repaint moving. then means Window cache produce, Controls produce, WndProcs settle, Window visible make. then have whole Neuzeichenkram too slay.
hint: there/ If you XPSE einsetzt, is the Tilde-characters ~ for Apis not necessary.
Info: Globals in nProc are readonly, your code means so not funktionsfähig. hint: Nutze GWL_USERDATA for each Control, circa therein one Extraspeicherhandle To platzieren circa itself above against global items How brush& To remember. |
| | | | |
| |  Ernst | thanks for Info and Tip; (The ~ use I only, since the APIs therefore in the IDE farblich highlighted go)
hint: Nutze GWL_USERDATA ...
Have me time with GWL_USERDATA attempts:
{$iq}
$H windows.ph
$H messages.ph
Declare brush&,dlg&, edit&
usermessages 16
Window Style 26
Window 100,100-500,300
CLS RGB(212,208,200)
dlg& = Control("DIALOG","",$54000000,50,200,200,20,%hwnd,0,%hinstance,0)
edit& = Create("EDIT",dlg&,"",0,0,width(dlg&),height(dlg&))
brush& = ~CreateSolidBrush(RGB(255,255,170))
~setWindowLong(dlg&,~gwl_userData,~setWindowLong(dlg&,~gwl_wndProc,procaddr(dlg_CP)))
setfocus(edit&)
While 1
Waitinput
IF %Umessage = 16
MessageBox("","",0)
break
endif
EndWhile
deleteobject brush&
End
' *******************************************************************************************************************
nProc dlg_CP
parameters Wnd&, Msg&, wParam&, lParam&
global brush&
IF Msg& = ~WM_CTLCOLOREDIT
~SetBkMode(wParam&,~transparent)
~SetTextColor(wParam&,RGB(0,0,255))
Return brush&
EndIf
return ~callWindowProc(~getWindowLong(wnd&,~gwl_userData),Wnd&, Msg&, wParam&, lParam&)
Endproc
..., circa therein one Extraspeicherhandle To platzieren ... the durchschaue I do not (How one something like power). I Have me too the Subclassing-example [...] respected - this is for me one gord-Knoten; I komm on none grüen sprig... |
| | | | |
|
AnswerThemeninformationenthis Topic has 2 subscriber: |