|
07-03-2023, 11:53 PM
|
#1
|
Human being with feelings
Join Date: Mar 2016
Posts: 47
|
Cannot edit or even read information about a RichEdit
I added a RichEdit in my control:
Code:
HWND CreateRich(HWND hWnd, int X, int Y, int W, int H) {
HWND hEl;
HINSTANCE mHInstance=0;
LoadLibrary("Riched20.dll");
hEl=CreateWindow(RICHEDIT_CLASS, "",
ES_MULTILINE | WS_VISIBLE | WS_CHILD | ES_READONLY, X, Y, W, H, hWnd, NULL, mHInstance, NULL);
HFONT hfont = CreateFont(15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
SendMessage(hEl, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(FALSE,0));
SendMessage(hEl, EM_SETBKGNDCOLOR, 0, RGB(15, 15, 15));
SetFocus(hEl);
return hEl;
}
.....
hLogs=CreateInput((HWND)mPlug->GetGUI()->GetWindow(), x, y, w, h);
It seems that I cannot edit or even read information about a RichEdit outside of Draw().
The program crashes even if I call SendMessage(hLogs, EM_GETLINECOUNT, 0, 0); - very strange. Why is this happening ?
I need to edit this control outside of Draw()
How can I do this?
Last edited by FelixMagi; 07-04-2023 at 03:18 AM.
|
|
|
07-04-2023, 03:04 AM
|
#2
|
Human being with feelings
Join Date: Mar 2016
Posts: 47
|
I see
Code:
HFONT hfont = (HFONT)SendMessage((HWND)mPlug->GetGUI()->GetWindow(), WM_GETFONT, NULL, NULL);
crash the plugin as well, this means serious problems in the Windows API implementation.
Last edited by FelixMagi; 07-04-2023 at 04:19 AM.
|
|
|
07-04-2023, 04:56 AM
|
#3
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,591
|
Maybe mPlug or mPlug->GetGUI() is somehow NULL?
|
|
|
07-04-2023, 05:36 AM
|
#4
|
Human being with feelings
Join Date: Mar 2016
Posts: 47
|
Code:
if (mPlug->GetGUI()!=NULL && mPlug->GetGUI()->GetWindow()!=NULL)
SendMessage((HWND)mPlug->GetGUI()->GetWindow(), WM_GETFONT, NULL, NULL);
crash too
|
|
|
07-04-2023, 06:32 AM
|
#5
|
Human being with feelings
Join Date: Aug 2013
Posts: 229
|
Works from anywhere, not just from the Draw(), but not from ProcessDoubleReplacing(). Check better here, you cannot call SendMessage() from ProcessDoubleReplacing.
|
|
|
07-04-2023, 07:03 AM
|
#6
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,591
|
Yeah, you should probably call this from the GUI thread. Here is seems to work fine if I call it from e.g. IControl::OnMouseDblClick(). Do note it seems to return NULL though.
|
|
|
07-04-2023, 10:42 PM
|
#7
|
Human being with feelings
Join Date: Mar 2016
Posts: 47
|
Quote:
Originally Posted by SaschArt
Works from anywhere, not just from the Draw(), but not from ProcessDoubleReplacing(). Check better here, you cannot call SendMessage() from ProcessDoubleReplacing.
|
Indeed, that was it, problem solved
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:04 PM.
|