After spending a lot of time trying to understand what I happening, I have
discovered the problem. The ComboBox is a child of the ComboBoxEx; however,
when the ComboBox moves itself or is moved by the parent, the move does not
take into account the parent/child relationship and the ComboBox is moved
relative to the parent dialog, not the parent (ComboBoxEx). Therefore the new
co-ordinates of the Comobox is completely wrong.
I have a Word document showing the results of SPY during the operation, but
I can't attach it here.
The solution I have used is to the following after moving the ComboBoxEx:
GetWindowRect(hWndComboBoxEx, &rc2);
hWnd2 = (HWND) SendMessage(hWndComboBoxEx, CBEM_GETCOMBOCONTROL, 0, 0);
MapWindowPoints(NULL, hWndComboBoxEx, (POINT *) &rc2, 2);
MoveWindow(hWnd2, rc2.left, rc2.top, rc2.right - rc2.left,rc2.bottom -
rc2.top, 0);
Also double-check with Spy++ that the ComboBox has the WS_CHILD style. Maybe you are messing with the styles and clear the WS_CHILD bit. Another thing to keep in mind is that combo boxes ignore the height when resized.
"Robin Ehrlich" <RobinE...@discussions.microsoft.com> wrote in message news:3A315466-C0CB-4DCD...@microsoft.com...
I am reporting a bug in WIN32 ComboBoxEx handling of the MoveWindow. I know
that I should not have to move the ComboBox child window myself, the
ComboBoxEx should handle it correctly, but it doesn't.
The "white box" you describe might be the result of not processing messages,
or processing them incorrectly.
"Robin Ehrlich" <RobinE...@discussions.microsoft.com> wrote in message
news:3227C13C-51D4-4236...@microsoft.com...
Robin
#define UNICODE
#include <windows.h>
#include <commctrl.h>
#pragma comment(linker,"/OPT:NOWIN98")
BOOL CALLBACK WndProc(HWND h, UINT MyMSG, WPARAM wp, LPARAM lp)
{
COMBOBOXEXITEM cbi;
switch (MyMSG)
{
case WM_COMMAND:
switch (wp)
{
case 2: EndDialog(h,0); break;
case 10: MoveWindow(GetDlgItem(h,11),0,0,100,100,TRUE); break;
}
break;
case WM_INITDIALOG:
cbi.mask = CBEIF_TEXT;
cbi.pszText = TEXT("Hello");
cbi.iItem = 0;
SendDlgItemMessage(h,11,CBEM_INSERTITEM,0,reinterpret_cast<LPARAM>(&cbi));
break;
}
return FALSE;
}
int WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR lpCmdLine,int nCmdShow)
{
InitCommonControls();
DialogBoxParam(NULL,MAKEINTRESOURCE(1),NULL,WndProc,0);
ExitProcess(0);
return 0;
}
This is the RC file
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
1 DIALOG DISCARDABLE 0, 0, 183, 77
STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_MINIMIZEBOX |
WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 9, "Tahoma"
BEGIN
CONTROL "",11,"ComboBoxEx32",CBS_DROPDOWN | CBS_SORT |
WS_VSCROLL | WS_TABSTOP,38,34,135,30
PUSHBUTTON "Move Combo to 0,0",10,91,53,83,14
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
"Robin Ehrlich" <RobinE...@discussions.microsoft.com> 撰寫於郵件新聞:51F98C5E-D0FB-49BB...@microsoft.com...
Robin
"Frank Cheng" wrote:
> "Robin Ehrlich" <RobinE...@discussions.microsoft.com> ¼¶¼g©ó¶l¥ó·s»D:51F98C5E-D0FB-49BB...@microsoft.com...
"Robin Ehrlich" <RobinE...@discussions.microsoft.com> wrote in message
news:1C23F0AD-C79D-441A...@microsoft.com...