API bug ?
Moderators: Hacker, petermad, Stefan2, white
API bug ?
Hello,
I'm trying to develop a wlx plugin.
I have a problem when I try to GetClientRect on the ParentWin parameter coming from ListLoad().
When ListLoad() is called, GetClientRect fill the RECT structure with 0. All fields are set to 0. So, the size of my windows is 0,0 => problem. GetClientRect returns non false, there is no error raised by the fonction.
Something strange is : When I press F3 => my window is created with size 0,0. Then, I don't press F3 to close the plugin, I just change the focus on another file in the TCM pannel. This time, the same hwnd than before is sent through ListLoad, but GetClientRect returns corrects values and my window is created normally.
Have you ever seen this ?
Thank you
I'm trying to develop a wlx plugin.
I have a problem when I try to GetClientRect on the ParentWin parameter coming from ListLoad().
When ListLoad() is called, GetClientRect fill the RECT structure with 0. All fields are set to 0. So, the size of my windows is 0,0 => problem. GetClientRect returns non false, there is no error raised by the fonction.
Something strange is : When I press F3 => my window is created with size 0,0. Then, I don't press F3 to close the plugin, I just change the focus on another file in the TCM pannel. This time, the same hwnd than before is sent through ListLoad, but GetClientRect returns corrects values and my window is created normally.
Have you ever seen this ?
Thank you
- ghisler(Author)
- Site Admin
- Posts: 50475
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Can you give me more infomation, please? For testing, I have added a small piece of code directly in front of ListLoad which calls GetClientRect. This gives me the correct values both when I press F3 and when I press Ctrl+Q. Tested with Total Commander 32-bit on Windows 7 x64.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Thank for your answer. I use TCM 8.5 on windows XP Pro 32bits.
I have tried with several others plugins (wlx plugin sample) and debugged them. I have the same problem at first F3 call. But the windows is resized later by a WM_SIZE message. So with the others plugins the window has the correct size.
With my plugin I never recveive WM_SIZE
I have tried with several others plugins (wlx plugin sample) and debugged them. I have the same problem at first F3 call. But the windows is resized later by a WM_SIZE message. So with the others plugins the window has the correct size.
With my plugin I never recveive WM_SIZE
- ghisler(Author)
- Site Admin
- Posts: 50475
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Do you create your plugin as a child of ParentWin?
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
I have found a walkaround.
m_myHwnd = CreateWindow(...)
ShowWindow(m_myHwnd, SW_SHOW);
UpdateWindow(m_myHwnd);
After My window is created I use PostMessage to send a custom message 123456
PostMessage(m_myHwnd, 123456, NULL, NULL);
When I receive it in the wndproc of the window I call GetClientRect on the parent of the hwnd which is passed in parameter :
LRESULT CALLBACK MainWindow::wlxPluginProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case 123456:
HWND parent = NULL;
parent = GetParent(hwnd);
GetClientRect(parent, &r);
MoveWindow(hwnd, 0, 0, r.right-r.left, r.bottom-r.top, TRUE);
When GetClientRect is called in this context, the values returned are corrects. I don't know why ...
m_myHwnd = CreateWindow(...)
ShowWindow(m_myHwnd, SW_SHOW);
UpdateWindow(m_myHwnd);
After My window is created I use PostMessage to send a custom message 123456
PostMessage(m_myHwnd, 123456, NULL, NULL);
When I receive it in the wndproc of the window I call GetClientRect on the parent of the hwnd which is passed in parameter :
LRESULT CALLBACK MainWindow::wlxPluginProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case 123456:
HWND parent = NULL;
parent = GetParent(hwnd);
GetClientRect(parent, &r);
MoveWindow(hwnd, 0, 0, r.right-r.left, r.bottom-r.top, TRUE);
When GetClientRect is called in this context, the values returned are corrects. I don't know why ...
Side note: message code 123456 - which is 0x1E240 in hex - is out of the allowed range. Documentation of the RegisterWindowMessage API function says:vfloyd wrote:I use PostMessage to send a custom message 123456
And:For sending private messages within a window class, an application can use any integer in the range WM_USER through 0x7FFF
Even if truncated to lower 16 bits, 0xE240 may still collide with the range reserved for RegisterWindowMessage function.If the message is successfully registered, the return value is a message identifier in the range 0xC000 through 0xFFFF.
Regards