Click here to Skip to main content
15,891,431 members

Child window combobox behaviour

Ernst G. Gruber asked:

Open original thread
Gentle people,
I simply just don't understand ...
There is a Combobox child window. If I set the focus to this combobox, I can enter the desired text and it is shown in the box, but I am unable to check whether the user has completed his entry. I.e. I get all CB notifications under WM_COMMAND, but none in WM_CHAR or WM_KEYDOWN. On the other hand if I inactivate the SetFocus to this combobox, I am unable to enter text. I.e. I get none of the CB notifications under WM_COMMAND, but WM_CHAR or WM_KEYDOWN work well ...

Could somebody please explain and give me an idea how to proceed? Any help will be appreciated!

The following simple piece of code already shows this behaviour:

int APIENTRY _tWinMain (HINSTANCE hInstance,
                        HINSTANCE hPrevInstance,
                        LPTSTR    lpCmdLine,
                        int       nCmdShow)
{           :
  	    :
  	    :
// Create Main window  	    	
  LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  hWnd  = CreateWindow (szWindowClass,szTitle,
                        WS_TILED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU,
                        100,100,905,667,NULL,NULL,hInstance,NULL);  
// Create Combobox Child window  	    	                        
  LoadString(hInstance, IDC_CMB, szClass, MAX_LOADSTRING);
  hListtitel = CreateWindow(szClass,"",
                        WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | _VSCROLL,   
                        200, 170, 540, 400,hWnd,NULL,hInstance,NULL);   
  InvalidateRect(hWnd,NULL,TRUE); 
  ShowWindow(hWnd, SW_SHOWNORMAL);
  UpdateWindow(hWnd);
  SetFocus(hListtitel);       <----------------------------------
  
  while (GetMessage(&msg, NULL, 0, 0))
  {
    if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
    {
      TranslateMessage(&msg);
      DispatchMessage(&msg); 
    }
  }
  return (int) msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  switch (message)
  {         :
  	    :
  	    :
    case WM_CHAR: 
     /*     do something     */
      break; 
            :
  	    :
  	    :
    case WM_COMMAND:
      wmEvent = HIWORD(wParam);
      if ((hListtitel != 0) && (lParam == (LPARAM)hListtitel))
      {
        switch (wmEvent)
			  {
       	  case CBN_EDITUPDATE: 
     /*     do something     */
            break; 
       	  case CBN_KILLFOCUS:  
     /*     do something     */
            break; 
          case CBN_SELCHANGE:  
     /*     do something     */
            break; 
          }	
        break; 
      }
  }
  return DefWindowProc(hWnd, message, wParam, lParam);

}
Tags: C++, Windows

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900