Child Fenster - ChildIcon verschiebt FrameMenu



  • ...oder Screenshots posten - mir ist gerade nich klar wie ich mir das vorstellen soll 😉



  • Hi,

    hier mal der Code bis auf die Resource:

    Danke
    Buster

    #include <WINDOWS.H>
    #include "COMMDLG.HPP"
    #include "RESOURCE.HPP"
    
    TCHAR szAppName[]    = TEXT ( "PROG" ) ;
    TCHAR szAppVersion[] = TEXT ( "PROG Version 2" ) ;  
    
    const char szChildName[] = "ChildWindow";
    
    #define IDM_WINDOWCHILD 50000
    
    LRESULT CALLBACK WndProc      ( HWND, UINT, WPARAM, LPARAM ) ;
    LRESULT CALLBACK ChildProc    ( HWND, UINT, WPARAM, LPARAM ) ;
    BOOL    CALLBACK LogonDlgProc ( HWND, UINT, WPARAM, LPARAM ) ;
    HWND    APIENTRY NewChildWin  ( HINSTANCE hInstance, HWND hwndClient ) ;
    
    int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
    {
      HWND      hwnd ;
      MSG       msg ;
      WNDCLASS  wndclass ;
    
      wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
      wndclass.lpfnWndProc   = WndProc ;
      wndclass.cbClsExtra    = 0 ;
      wndclass.cbWndExtra    = 0 ;
      wndclass.hInstance     = hInstance ;
      wndclass.hIcon         = LoadIcon ( hInstance, MAKEINTRESOURCE ( IDI_ICON ) ) ;
      wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW ) ;
      wndclass.hbrBackground = ( HBRUSH ) GetStockObject ( GRAY_BRUSH ) ;
      wndclass.lpszMenuName  = "XINFO" ;
      wndclass.lpszClassName = szAppName ;
    
      if ( !RegisterClass ( &wndclass ) )
      {
          MessageBox ( NULL, TEXT ( "This program requires Windows NT, 2000 or XP!" ), szAppName, MB_ICONERROR ) ;
          return 0 ;
      }
    
      wndclass.lpfnWndProc   = ChildProc ;
      wndclass.cbWndExtra    = 0 ; 
      wndclass.hIcon         = NULL ;
      wndclass.hbrBackground = ( HBRUSH ) GetStockObject ( WHITE_BRUSH ) ;
      wndclass.lpszMenuName  = NULL ;
      wndclass.lpszClassName = szChildName ;
    
      RegisterClass ( &wndclass ) ;
    
      hwnd = CreateWindow ( szAppName,
                            szAppVersion,
                            WS_OVERLAPPEDWINDOW,
                            CW_USEDEFAULT,
                            CW_USEDEFAULT,
                            CW_USEDEFAULT,
                            CW_USEDEFAULT,
                            NULL,
                            NULL,
                            hInstance,
                            NULL ) ;
    
      ShowWindow   ( hwnd, iCmdShow ) ;
      UpdateWindow ( hwnd ) ;
    
      while ( GetMessage ( &msg, NULL, 0, 0 ) )
      {
          TranslateMessage ( &msg ) ;
          DispatchMessage ( &msg ) ;
      }
      return msg.wParam ;
    }
    
    LRESULT CALLBACK WndProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
    {
      static HINSTANCE   hInstance ;
      static HWND        hwndClient ;
      CLIENTCREATESTRUCT clientcreate ;
      static TCHAR       szFileName[MAX_PATH], szTitleName[MAX_PATH] ;
      static HWND        hChild ;
    
      switch ( message )
      {
      case WM_CREATE:
        hInstance = ( ( LPCREATESTRUCT ) lParam )->hInstance ;
        CommonDlgInit ( hwnd, hInstance ) ;
    
        clientcreate.hWindowMenu  = GetSubMenu ( GetMenu( hwnd ), XINFO ) ;
        clientcreate.idFirstChild = IDM_WINDOWCHILD ; 
        hwndClient = CreateWindow ( "MDICLIENT",
                                    ( LPCTSTR ) NULL, 
                                    WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL, 
                                    0,
                                    0,
                                    0,
                                    0,
                                    hwnd,
                                    ( HMENU ) 0xCAC,
                                    hInstance,
                                    ( LPSTR ) &clientcreate ) ; 
    
        ShowWindow ( hwndClient, SW_SHOW ) ;
        return 0 ;
    
      case WM_COMMAND:
        switch ( LOWORD ( wParam ) )
        {
        case IDM_FILE_LOGON:
          DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_LOGON ), hwnd, LogonDlgProc ) ;
          return 0 ;
    
        case IDM_FILE_EXIT:
          SendMessage ( hwnd, WM_CLOSE, 0, 0 ) ;
          return 0 ;
    
        case IDM_FILE_OPEN:
          FileOpenDlg ( hwnd, szFileName, szTitleName );
          return 0 ;
    
        case IDM_FILE_SAVE_AS:
          if ( FileSaveDlg ( hwnd, szFileName, szTitleName ) )
          {
            ; //File schreiben !!!
          }
          return 0 ;
    
        case IDM_HELP_HELP:
          MessageBox ( hwnd, TEXT ( "Help not yet implemented!" ), szAppName, MB_ICONEXCLAMATION | MB_OK ) ;
          return 0 ;
    
        case IDM_FILE_STARTPANEL:
          NewChildWin ( hInstance, hwndClient ) ;
          return 0 ;
    
        case IDM_HELP_\1:
          char MessageOut[100] = "" ;
          strcat ( MessageOut, szAppVersion ) ;
          strcat ( MessageOut, " - " ) ;
          strcat ( MessageOut, "bla bla" ) ;
          MessageBox ( hwnd, MessageOut, szAppName, MB_ICONINFORMATION | MB_OK ) ;
          return 0 ;
        }
        break ;
    
      case WM_DESTROY:
        PostQuitMessage ( 0 ) ;
        return 0 ;
      }
      return DefFrameProc ( hwnd, hwndClient, message, wParam, lParam ) ;
    }
    
    BOOL CALLBACK LogonDlgProc ( HWND hDlg, UINT message, 
                                 WPARAM wParam, LPARAM lParam )
    {
      switch ( message )
      {
      case WM_INITDIALOG:
          //Laden der zuletzt eingegebenen Daten
          //SetFocus (GetDlgItem (hDlg, iColor)) ;
          return TRUE ;
    
      case WM_COMMAND:
          switch ( LOWORD ( wParam ) )
          {
          case IDOK:
            EndDialog ( hDlg, TRUE ) ;
            return TRUE ;
    
          case IDCANCEL:
            EndDialog ( hDlg, FALSE ) ;
            return TRUE ;
          }
          break ;
      }
      return FALSE ;
    }
    
    LRESULT CALLBACK ChildProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
    {
      return DefMDIChildProc ( hwnd, message, wParam, lParam ) ;
    }
    
    HWND APIENTRY NewChildWin ( HINSTANCE hInstance, HWND hwndClient ) 
    {
      HWND hwnd ; 
      CHAR sz[160] ; 
      MDICREATESTRUCT mcs ;  
    
      mcs.szTitle = "NEW" ; 
      mcs.szClass = szChildName ; 
      mcs.hOwner  = hInstance ; 
    
      // Use the default size for the child window. 
    
      mcs.x = mcs.cx = CW_USEDEFAULT ; 
      mcs.y = mcs.cy = CW_USEDEFAULT ; 
    
      // Give the child window the default style. The styleDefault 
      // variable is defined in MULTIPAD.C. 
    
      mcs.style = NULL ; 
    
      // Tell the MDI client window to create the child window. 
    
      hwnd = ( HWND ) SendMessage ( hwndClient, WM_MDICREATE, 0, 
             ( LONG ) ( LPMDICREATESTRUCT ) &mcs ); 
    
      return hwnd ; 
    }
    


  • Screenshots wieder draussen

    Buster

    [ Dieser Beitrag wurde am 10.01.2003 um 16:29 Uhr von Buster editiert. ]



  • Dann mußt du eben das Maximier-Verhalten deines Child-Fensters selbst handhaben. Aber was ist so schlimm daran, das sich das Icon ins Menü setzt? Ist doch schön so. 🙂



  • Hallo Baracuda,

    ist halt Geschmackssache, also Du meinst, ohne standard Maximize keine andere Chance? Irgendwelche Flags die mir noch fast alle unbekannt sind?

    THX
    Buster



  • Hallo Buster,

    das ist glaub ich nicht durch irgendwelche Flags änderbar. Aber wie soll sich das Fenster denn sonst bei der Maximierung verhalten? 😕



  • Hallo Baracuda,

    wenn ich schon beim Icon "NULL" wähle, soll erstens kein defrault Icon verwand werden und zweitens auch das Menü links bleiben. So war meine Vorstellung. 🙄

    Cu
    Buster



  • Kann man überhaupt owerlapped windows ohne icons erstellen? ich glaube nicht. 😃



  • hIcon
    Handle to the class icon. This member must be a handle to an icon resource. If this member is NULL, the system provides a default icon.

    Es geht einfach nicht ohne Icon. 🙄



  • @Deadboy,

    danke und schade!

    Wenn ich dann mal soweit sein sollte, dass ich einen Plan von der API habe, dann programmiere ich das Handling selber 😃 😕

    Bis dahin .....

    Buster


Anmelden zum Antworten