/****************************************************************************
*
*     FUNCTION: WndProc
*
*     PURPOSE:  Window Procedure for the main window.
*
*     PARAMS:   HWND   hWnd    - This window
*               UINT   Message - Which message?
*               WPARAM wParam  - message parameter
*               LPARAM lParam  - message parameter
*
*     RETURNS:  LRESULT - depends on message
*
* History:
*                July '95 - Created
*
\****************************************************************************/
LRESULT CALLBACK WndProc( HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam )
{
    // which message are we handling?
    switch( Message )
    {
        // Menu is coming up, initialize it
        case WM_INITMENU:
            UpdateMenuState( hWnd, (HMENU)wParam );
            return 1;
        break; // end WM_INITMENU

        // Window is being created, create the MDI client also
        case WM_CREATE:
        {
            CLIENTCREATESTRUCT ccs;

            // Retrieve the handle of the Window menu and assign the
            // first child window identifier.
            ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), 2 );
            ccs.idFirstChild = IDM_WINDOWCHILD;

            // Create the MDI client window
            hMDIClientWnd = CreateWindow(	TEXT("MDICLIENT"), (LPCTSTR) NULL,
                                            WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
                                            0, 0, 0, 0, hWnd, (HMENU) 0xCAC, hInst, (LPSTR) &ccs );

            ShowWindow(hMDIClientWnd, SW_SHOW);
        }
        break; // End WM_CREATE

        // Command Messages (menu items, etc)
        case WM_COMMAND:
            OnCommand( hWnd, wParam, lParam );
            return DefFrameProc( hWnd, hMDIClientWnd, Message, wParam, lParam );
        break; // End WM_COMMAND

        // Time to close down now :(
        case WM_CLOSE:
        {
            // Will the children allow it? (Give 'em a chance to cancel)
            if( QueryCloseAllChildren() )
            {
                WinHelp( hWnd, szHelpFileName, HELP_QUIT, 0 );
                DestroyWindow( hWnd );
                PostQuitMessage( 0 );
                return DefFrameProc( hWnd, hMDIClientWnd, Message, wParam, lParam );
            }
            return 0;
        }
        break; // End WM_CLOSE

        // Pass it on to the default window procedure
        default:
            return DefFrameProc( hWnd, hMDIClientWnd, Message, wParam, lParam );
        break; // end default
    }
    return DefFrameProc( hWnd, hMDIClientWnd, Message, wParam, lParam );
}
Пример #2
0
/*------------------------------------------------------------------------
Procedure:     MainWndProc ID:1
Purpose:       Window procedure for the frame window, that contains
the menu. The messages handled are:
WM_CREATE: Creates the mdi child window
WM_SIZE: resizes the status bar and the mdi child
window
WM_COMMAND: Sends the command to the dispatcher
WM_CLOSE: If the user confirms, it exists the program
WM_QUITOCAML: Stops the program unconditionally.
Input:         Standard windows callback
Output:
Errors:
------------------------------------------------------------------------*/
static LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch (msg) {
		// Create the MDI client invisible window
		case WM_CREATE:
			hwndMDIClient = CreateMdiClient(hwnd);
			TimerId = SetTimer((HWND) 0, 0, 100, (TIMERPROC) TimerProc);
			break;
			// Move the child windows
		case WM_SIZE:
			SendMessage(hWndStatusbar,msg,wParam,lParam);
			InitializeStatusBar(hWndStatusbar,1);
			// Position the MDI client window between the tool and status bars
			if (wParam != SIZE_MINIMIZED) {
				RECT rc, rcClient;

				GetClientRect(hwnd, &rcClient);
				GetWindowRect(hWndStatusbar, &rc);
				ScreenToClient(hwnd, (LPPOINT)&rc.left);
				rcClient.bottom = rc.top;
				MoveWindow(hwndMDIClient,rcClient.left,rcClient.top,rcClient.right-rcClient.left, rcClient.bottom-rcClient.top, TRUE);
			}

			return 0;
			// Dispatch the menu commands
		case WM_COMMAND:
			HandleCommand(hwnd, wParam,lParam);
			return 0;
			// If user confirms close
		case WM_CLOSE:
			if (!AskYesOrNo("Quit OCamlWinPlus?"))
				return 0;
			break;
			// End application
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
			// The interpreter has exited. Force close of the application
		case WM_QUITOCAML:
			DestroyWindow(hwnd);
			return 0;
		case WM_USER+1000:
			// TestGraphics();
			break;
		default:
			return DefFrameProc(hwnd,hwndMDIClient,msg,wParam,lParam);
	}
	return DefFrameProc(hwnd,hwndMDIClient,msg,wParam,lParam);
}
Пример #3
0
int CMainFrame::MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
    case WM_COMMAND:
      OnCommand(wParam, lParam);
      break;
    case WM_CREATE:
      OnCreate(wParam, lParam);
      break;
    case WM_DESTROY:
      OnDestroy(wParam, lParam);
      break;
    case WM_SIZE:
      OnSize(wParam, lParam);
      return 1;
    case WM_TIMER:
      OnTimer(wParam, lParam);
      return 1;
    case WM_ERASEBKGND:
      return 0;
  }

  return DefFrameProc(m_hWnd, m_hClient, uMsg, wParam, lParam);
}
Пример #4
0
static LRESULT CALLBACK MAIN_MainWndProc(HWND hWnd, UINT msg,
				 WPARAM wParam, LPARAM lParam)
{
#if 0
  printf("M %4.4x %4.4x\n", msg, wParam);
#endif
  switch (msg)
    {
    case WM_INITMENU:
      CheckMenuItem(Globals.hOptionMenu, PM_AUTO_ARRANGE,
		    MF_BYCOMMAND | (Globals.bAutoArrange ? MF_CHECKED : MF_UNCHECKED));
      CheckMenuItem(Globals.hOptionMenu, PM_MIN_ON_RUN,
		    MF_BYCOMMAND | (Globals.bMinOnRun ? MF_CHECKED : MF_UNCHECKED));
      CheckMenuItem(Globals.hOptionMenu, PM_SAVE_SETTINGS,
		    MF_BYCOMMAND | (Globals.bSaveSettings ? MF_CHECKED : MF_UNCHECKED));
      break;

    case WM_COMMAND:
      if (wParam < PM_FIRST_CHILD)
	MAIN_MenuCommand(hWnd, wParam, lParam);
      break;

    case WM_DESTROY:
      PostQuitMessage (0);
      break;
    }
  return(DefFrameProc(hWnd, Globals.hMDIWnd, msg, wParam, lParam));
}
Пример #5
0
static LRESULT CALLBACK winDialogMDIFrameProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
    LRESULT result;
    HWND hWndClient = NULL;
    Ihandle *ih = iupwinHandleGet(hwnd);
    if (!ih)
    {
        /* the first time WM_GETMINMAXINFO is called, Ihandle is not associated yet */
        if (msg == WM_GETMINMAXINFO && winMinMaxHandle)
        {
            if (winDialogCheckMinMaxInfo(winMinMaxHandle, (MINMAXINFO*)lp))
                return 0;
        }

        return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
    }

    {
        Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
        if (client) hWndClient = client->handle;
    }

    if (winDialogBaseProc(ih, msg, wp, lp, &result))
        return result;

    if (msg == WM_MENUCOMMAND)
    {
        int menuId = GetMenuItemID((HMENU)lp, (int)wp);
        if (menuId >= IUP_MDI_FIRSTCHILD && hWndClient)
        {
            /* we manually activate the MDI child when its menu item is selected. */
            HWND hChild = GetDlgItem(hWndClient, menuId);
            if (hChild)
                SendMessage(hWndClient, WM_MDIACTIVATE, (WPARAM)hChild, 0);
        }
        else if (menuId >= SC_SIZE && menuId <= SC_CONTEXTHELP)
        {
            /* we manually forward the message to the MDI child */
            HWND hChild = (HWND)SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0);
            if (hChild)
                SendMessage(hChild, WM_SYSCOMMAND, (WPARAM)menuId, 0);
        }
    }

    return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
}
Пример #6
0
static LRESULT CALLBACK winDialogMDIFrameProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{   
  LRESULT result;
  HWND hWndClient = NULL;
  Ihandle *ih = iupwinHandleGet(hwnd); 
  if (!ih)
  {
    /* the first time WM_GETMINMAXINFO is called, Ihandle is not associated yet */
    if (msg == WM_GETMINMAXINFO && winMinMaxHandle)
    {
      if (winDialogCheckMinMaxInfo(winMinMaxHandle, (MINMAXINFO*)lp))
        return 0;
    }

    return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
  }

  {
    Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
    if (client) hWndClient = client->handle;
  }

  if (winDialogBaseProc(ih, msg, wp, lp, &result))
    return result;

  switch (msg)
  {
  case WM_MENUCOMMAND:
    {
      int menuId = GetMenuItemID((HMENU)lp, (int)wp);
      if (menuId >= IUP_MDICHILD_START && hWndClient)
      {
        Ihandle* child = winDialogGetMdiChildId(ih, menuId-IUP_MDICHILD_START);
        if (child)
          SendMessage(hWndClient, WM_MDIACTIVATE, (WPARAM)child->handle, 0);
        break;
      }
    }
  }


  return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
}
Пример #7
0
WXLRESULT wxMDIParentFrame::MSWDefWindowProc(WXUINT message,
                                        WXWPARAM wParam,
                                        WXLPARAM lParam)
{
    WXHWND clientWnd;
    if ( GetClientWindow() )
        clientWnd = GetClientWindow()->GetHWND();
    else
        clientWnd = 0;

    return DefFrameProc(GetHwnd(), (HWND)clientWnd, message, wParam, lParam);
}
Пример #8
0
static VOID
FrameOnCommand(HWND hwnd,
               UINT uMsg,
               WPARAM wParam,
               LPARAM lParam)
{
    PCONSOLE_MAINFRAME_WND Info;
    HWND hChild;

    Info = (PCONSOLE_MAINFRAME_WND)GetWindowLongPtr(hwnd, 0);

    switch (LOWORD(wParam))
    {
        case IDM_FILE_NEW:
            CreateNewMDIChild(Info, hwndMDIClient);
            SetMenu(Info->hwnd,
                    Info->hMenuConsoleLarge);
            break;

        case IDM_FILE_SAVE:
            FrameOnSave(hwnd);
            break;

        case IDM_FILE_SAVEAS:
            FrameOnSaveAs(hwnd);
            break;

        case IDM_FILE_EXIT:
            PostMessage(hwnd, WM_CLOSE, 0, 0);
            break;

        default:
            if (LOWORD(wParam) >= IDM_MDI_FIRSTCHILD)
            {
                DefFrameProc(hwnd, hwndMDIClient, uMsg, wParam, lParam);
            }
            else
            {
                hChild = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0);
                if (hChild)
                {
                    SendMessage(hChild, WM_COMMAND, wParam, lParam);
                }
            }
            break;
    }
}
Пример #9
0
LRESULT DispDefault(EDWP   edwp, 
                    HWND   hwnd, 
                    UINT   uMessage, 
                    WPARAM wparam, 
                    LPARAM lparam)
{
    switch (edwp)
    {
        case edwpNone:
            return 0;
        case edwpWindow:
            return DefWindowProc(hwnd, uMessage, wparam, lparam);
        case edwpDialog:
            return DefDlgProc(hwnd, uMessage, wparam, lparam);
        case edwpMDIFrame:
            return DefFrameProc(hwnd, hwndMDIIPXChat, uMessage, wparam, lparam);
        case edwpMDIChild:
            return DefMDIChildProc(hwnd, uMessage, wparam, lparam);
    }
    return 0;
}
Пример #10
0
long FAR PASCAL _export ProcVentApp (HWND hwnd, WORD message,
				     WORD wParam, LONG lParam)
{
 static HANDLE      hInstance;
 PAINTSTRUCT        ps;

 switch (message)
 {
  case WM_CREATE:
  {
   /* Obtenemos el handle a la ocurrencia del m�dulo, que se guarda forever */
   hInstance = ((LPCREATESTRUCT) lParam)->hInstance;

   return (0);
  }

  case WM_PAINT:
  {
   /* Obtenemos el contexto de la ventana */
   hdc = BeginPaint (hwnd, &ps);

   /* Redibujamos el MetaFile */
   PlayMetaFile (hdc, hMF);

   /* Liberamos el contexto */
   EndPaint (hwnd, &ps);

   return (0);
  }

  case WM_DESTROY:
  {
   PostQuitMessage (0);
   return (0);
  }
 }

 return (DefFrameProc (hwnd, hwndCliente, message, wParam, lParam));
}
Пример #11
0
/*
================
rvGEApp::FrameWndProc

Main frame window procedure
================
*/
LRESULT CALLBACK rvGEApp::FrameWndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    rvGEApp* app = (rvGEApp*) GetWindowLong ( hWnd, GWL_USERDATA );

    switch ( uMsg )
    {
    case WM_SIZE:
    {
        RECT rStatus;
        RECT rClient;

        // Tell the status bar to resize
        app->mStatusBar.Resize ( LOWORD(lParam), HIWORD(lParam) );

        // Calculate the new client window rectangle (minus the status bar)
        GetWindowRect ( app->mStatusBar.GetWindow ( ), &rStatus );
        GetClientRect ( hWnd, &rClient );

        if ( app->mOptions.GetStatusBarVisible ( ) )
        {
            rClient.bottom -= (rStatus.bottom-rStatus.top);
        }
        MoveWindow ( app->mMDIClient, 0, 0, rClient.right-rClient.left, rClient.bottom-rClient.top, FALSE );

        return 0;
    }

    case WM_ENABLE:
    {
        int i;

        // Synchronise all toolwindows to the same state.
        for(i = 0; i < app->mToolWindows.Num(); i++)
        {
            if(app->mToolWindows[i] != hWnd)
            {
                EnableWindow(app->mToolWindows[i], wParam);
            }
        }
        break;
    }

    case WM_NCACTIVATE:
        return app->ToolWindowActivate ( hWnd, uMsg, wParam, lParam );

    case WM_ACTIVATE:
        common->ActivateTool( LOWORD( wParam ) != WA_INACTIVE );
        break;

    case WM_INITMENUPOPUP:
        app->HandleInitMenu ( wParam, lParam  );
        break;

    case WM_CLOSE:
        while ( app->mWorkspaces.Num ( ) )
        {
            SendMessage ( app->mWorkspaces[0]->GetWindow ( ), WM_CLOSE, 0, 0 );
        }
        break;

    case WM_DESTROY:
        app->mOptions.SetWindowPlacement ( "mdiframe", hWnd );
        app->mOptions.Save ( );
        ExitProcess(0);
        break;

    case WM_COMMAND:
    {
        int result;
        assert ( app );
        result = app->HandleCommand ( wParam, lParam );
        if ( -1 != result )
        {
            return result;
        }
        break;
    }

    case WM_CREATE:
    {
        LPCREATESTRUCT		cs;

        cs = (LPCREATESTRUCT) lParam;
        app = (rvGEApp*)cs->lpCreateParams;

        assert ( app );

        SetWindowLong ( hWnd, GWL_USERDATA, (LONG)app );

        app->mMDIFrame = hWnd;

        app->InitRecentFiles ( );
        app->UpdateRecentFiles ( );
        app->mNavigator.Create ( hWnd, gApp.mOptions.GetNavigatorVisible ( ) );
        app->mTransformer.Create ( hWnd, gApp.mOptions.GetTransformerVisible ( )  );
        app->mStatusBar.Create ( hWnd, 9999, gApp.mOptions.GetStatusBarVisible ( )  );
        app->mProperties.Create ( hWnd, gApp.mOptions.GetPropertiesVisible ( ) );

        // add all the tool windows to the tool window array
        app->mToolWindows.Append ( app->mMDIFrame );
        app->mToolWindows.Append ( app->mNavigator.GetWindow ( ) );
        app->mToolWindows.Append ( app->mProperties.GetWindow ( ) );
        app->mToolWindows.Append ( app->mTransformer.GetWindow ( ) );

        SendMessage ( app->mNavigator.GetWindow ( ), WM_NCACTIVATE, true, (LONG)-1 );
        SendMessage ( app->mProperties.GetWindow ( ), WM_NCACTIVATE, true, (LONG)-1 );
        SendMessage ( app->mTransformer.GetWindow ( ), WM_NCACTIVATE, true, (LONG)-1 );

        break;
    }
    }

    return DefFrameProc ( hWnd, app?app->mMDIClient:NULL, uMsg, wParam, lParam );
}
Пример #12
0
LRESULT CALLBACK QTFrame_FrameWndProc (HWND theWnd, UINT theMessage, UINT wParam, LONG lParam)
{
	HWND       			myChild;

	switch (theMessage) {
	
		case WM_CREATE: {
			CLIENTCREATESTRUCT		myClientStruct = {0};

			myClientStruct.hWindowMenu  = GetSubMenu(GetMenu(theWnd), WINDOWMENU);
			myClientStruct.idFirstChild = IDM_WINDOWCHILD;
			
			// create the MDI client filling the client area
			ghWndMDIClient = CreateWindow("mdiclient",
										 NULL,
										 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
										 0, 0, 0, 0,
										 theWnd,
										 (HMENU)0xCAC,
										 ghInst,
										 (LPVOID)&myClientStruct);
			
			// set initial menu state
			QTFrame_AdjustMenus(NULL, GetMenu(theWnd), 0L);
			
			if (ghWndMDIClient != NULL)
				ShowWindow(ghWndMDIClient, SW_SHOW);
			
			return(0);
		}

		case WM_ACTIVATE:
			// the MDI frame window is being activated or deactivated;
			// activate or deactivate any active child window by sending this message to DefMDIChildProc 
			myChild = (HWND)SendMessage(ghWndMDIClient, WM_MDIGETACTIVE, 0, 0L);
			if (IsWindow(myChild))
				SendMessage(myChild, WM_ACTIVATE, wParam, lParam);
			break;

		case WM_COMMAND: {

			switch (LOWORD(wParam)) {
				case IDM_FILENEW:
				case IDM_FILEOPEN:
				case IDM_FILECLOSE:
				case IDM_EXIT:
					QTFrame_HandleFileMenuItem(NULL, LOWORD(wParam));
					return(0);

				case IDM_FILESAVE:
				case IDM_FILESAVEAS:
					// save the active child window
					myChild = (HWND)SendMessage(ghWndMDIClient, WM_MDIGETACTIVE, 0, 0L);
					if (IsWindow(myChild))
						SendMessage(myChild, WM_COMMAND, wParam, lParam);
					return(0);

				case IDM_WINDOWTILE:
					SendMessage(ghWndMDIClient, WM_MDITILE, 0, 0L);
					return(0);

				case IDM_WINDOWCASCADE:
					SendMessage(ghWndMDIClient, WM_MDICASCADE, 0, 0L);
					return(0);

				case IDM_WINDOWICONS:
					SendMessage(ghWndMDIClient, WM_MDIICONARRANGE, 0, 0L);
					return(0);

				case IDM_WINDOWCLOSEALL: {
					WindowReference		myWindow, myNextWindow;
			
					// walk the window list and destroy any open windows
					myWindow = QTFrame_GetFrontMovieWindow();
					while (myWindow != NULL) {
						myNextWindow = QTFrame_GetNextMovieWindow(myWindow);
						SendMessage(myWindow, WM_CLOSE, 0L, 0L);
						myWindow = myNextWindow;
					}
					
					return(0);
				}

				case IDM_ABOUT:
					QTFrame_ShowAboutBox();
					return(0);

				default:				
					// pass this message to the active child window...
					myChild = (HWND)SendMessage(ghWndMDIClient, WM_MDIGETACTIVE, 0, 0L);
					if (IsWindow(myChild))
						SendMessage(myChild, WM_COMMAND, wParam, lParam);

					// ...then do any application-specific menu handling, if no movie windows are open...
					if (myChild == NULL)
						QTApp_HandleMenu((UInt16)LOWORD(wParam));
					
					// ...and then pass it to DefFrameProc
					break;
			}
			break;
		}

		case WM_OPENDROPPEDFILES:
			// open any movie files that were dropped onto the application icon
			QTFrame_OpenCommandLineMovies(gCmdLine);
			return(0);

		case WM_INITMENU: {
			long		myModifiers = 0L;
			
			myModifiers = QTFrame_GetKeyboardModifiers();
			if (GetMenu(theWnd) == (HMENU)wParam)
				return(QTFrame_AdjustMenus((HWND)SendMessage(ghWndMDIClient, WM_MDIGETACTIVE, 0, 0L), (HMENU)wParam, myModifiers));
			return(1);
		}
		
		case WM_CLOSE:
			// if we're not already in the process of shutting down,
			// simulate the selection of the Quit menu command
			if (!gShuttingDown) {
				SendMessage(ghWnd, WM_COMMAND, IDM_EXIT, 0L);
				return(0);
			}
			break;
			
		case WM_DESTROY:
			// do any application-specific shutdown
			QTApp_Stop(kStopAppPhase_AfterDestroyWindows);
			PostQuitMessage(0);
			break;
	}
	
	return(DefFrameProc(theWnd, ghWndMDIClient, theMessage, wParam, lParam));
}
/*
	MainWndProc
*/
LRESULT CALLBACK MainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{

    CLIENTCREATESTRUCT	clientcreate;
	DWORD				dwStyle;	

    switch (message) 
    {

      case WM_CREATE:
        SetWindowLong(hwnd, 0, (LONG)NULL);
        clientcreate.hWindowMenu  = hMenuWindow;
        clientcreate.idFirstChild = 1;
	
		dwStyle = WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE;			

		// Create our child window
		ghwndClient = CreateWindow("MDICLIENT", NULL,
										dwStyle,
										0,0,0,0,
										hwnd, NULL, ghModule, (LPVOID)&clientcreate);

        return 0L;

      case WM_DESTROY: 
		PostQuitMessage(0);
        return 0L;

      case WM_SYSCOMMAND:
		if ( LOWORD(wParam) == MM_ABOUT)   {
			SendMessage(hwnd,WM_COMMAND,MM_ABOUT,0);
			return 0;
		} else
              return DefWindowProc (hwnd, message, wParam, lParam);
		break;

      case WM_COMMAND:

        switch (LOWORD(wParam)) 
        {
            
			// File Menu
			case ID_FILE_OPEN: 
				if(DoFileOpen(NULL))
					return 0L;
				break;
			
			case ID_FILE_CLOSE:
				DestroyWindow((HWND)SendMessage(ghwndClient, WM_MDIGETACTIVE, 0L, FALSE));
				break;

			case ID_FILE_EXIT:
	            PostMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
	            break;
			
			// Window Menu
            case IDM_TILE:
                SendMessage(ghwndClient, WM_MDITILE, 0L, 0L);
                return 0L;
            
			case IDM_CASCADE:
                SendMessage(ghwndClient, WM_MDICASCADE, 0L, 0L);
                return 0L;
            
			case IDM_ARRANGE:
                SendMessage(ghwndClient, WM_MDIICONARRANGE, 0L, 0L);
                return 0L;

            case ID_WINDOW_ABOUT:
                if (DialogBox(ghModule, "AboutBox", ghwndMain, (DLGPROC)About) == -1){
					MessageBox(ghwndMain, "About Dialog Creation Error!", "Error", MB_OK);
				}
				return 0L;

            default:
                return DefFrameProc(hwnd,  ghwndClient, message, wParam, lParam);
        }

    default:

        return DefFrameProc(hwnd,  ghwndClient, message, wParam, lParam);
    }
}
Пример #14
0
WINEXPORT LRESULT CALLBACK WdeMainWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    HMENU       menu;
    LRESULT     ret;
    bool        pass_to_def;
    WdeResInfo  *res_info;
    WORD        wp;
    about_info  ai;

    if( WdeCleanupStarted ) {
        if( message == WM_DESTROY ) {
            PostQuitMessage( 0 );
        }
        return( DefFrameProc( hWnd, hWinWdeMDIClient, message, wParam, lParam ) );
    }

    pass_to_def = TRUE;
    ret = FALSE;
    res_info = WdeGetCurrentRes();
    menu = WdeGetMenuHandle();

    switch( message ) {
    case WM_INITMENU:
        handleInitMenu( menu );
        break;

    case WM_USER:
        WdeSetStatusByID( -1, WDE_ONLYONEINSTANCE );
        break;

    case WM_MENUSELECT:
        WdeHandleMenuSelect( wParam, lParam );
        break;

    case WM_MEASUREITEM:
        WdeHandleMeasureItem( (MEASUREITEMSTRUCT *)lParam );
        ret = TRUE;
        pass_to_def = FALSE;
        break;

    case WM_DRAWITEM:
        WdeHandleDrawItem( (DRAWITEMSTRUCT *)lParam );
        ret = TRUE;
        pass_to_def = FALSE;
        break;

    case WM_MOVE:
        if( IsZoomed( hWnd ) ) {
            WdeSetOption( WdeOptIsScreenMax, TRUE );
        } else if( !IsIconic( hWnd ) ) {
            WdeUpdateScreenPosOpt();
            WdeSetOption( WdeOptIsScreenMax, FALSE );
        }
        break;

    case WM_SIZE:
        if( wParam == SIZE_MAXIMIZED ) {
            WdeSetOption( WdeOptIsScreenMax, TRUE );
        } else if( wParam != SIZE_MINIMIZED ) {
            WdeUpdateScreenPosOpt();
            WdeSetOption( WdeOptIsScreenMax, FALSE );
        }

        if( wParam != SIZE_MINIMIZED ) {
            WdeResizeWindows();
        }

        pass_to_def = FALSE;
        break;

    case WM_COMMAND:
        wp = LOWORD( wParam );
        if( !WdeIsMenuIDValid( menu, wp ) ) {
            break;
        }
        switch( wp ) {
        case IDM_SELECT_MODE:
        case IDM_DIALOG_TOOL:
        case IDM_PBUTTON_TOOL:
        case IDM_CBUTTON_TOOL:
        case IDM_RBUTTON_TOOL:
        case IDM_GBUTTON_TOOL:
        case IDM_FRAME_TOOL:
        case IDM_TEXT_TOOL:
        case IDM_ICON_TOOL:
        case IDM_EDIT_TOOL:
        case IDM_LISTBOX_TOOL:
        case IDM_COMBOBOX_TOOL:
        case IDM_HSCROLL_TOOL:
        case IDM_VSCROLL_TOOL:
        case IDM_SIZEBOX_TOOL:
        case IDM_STATUSBAR_TOOL:
        case IDM_LISTVIEW_TOOL:
        case IDM_TREEVIEW_TOOL:
        case IDM_TABCNTL_TOOL:
        case IDM_ANIMATE_TOOL:
        case IDM_UPDOWN_TOOL:
        case IDM_TRACKBAR_TOOL:
        case IDM_PROGRESS_TOOL:
        case IDM_HOTKEY_TOOL:
        case IDM_HEADER_TOOL:
        case IDM_CUSTOM1_TOOL:
        case IDM_CUSTOM2_TOOL:
            WdeSetBaseObject( wp );
            pass_to_def = FALSE;
            break;

        case IDM_STICKY_TOOLS:
            WdeToggleStickyTools();
            pass_to_def = FALSE;
            break;

        case IDM_FMLEFT:
        case IDM_FMRIGHT:
        case IDM_FMTOP:
        case IDM_FMBOTTOM:
        case IDM_FMVCENTRE:
        case IDM_FMHCENTRE:
        case IDM_ESCAPE:
        case IDM_DELETEOBJECT:
        case IDM_SPACE_HORZ:
        case IDM_SPACE_VERT:
            ret = WdePassToEdit( message, wParam, lParam );
            pass_to_def = FALSE;
            break;

        case IDM_SELECT_DIALOG:
            WdeSelectDialog( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_OPTIONS:
            WdeDisplayOptions ();
            pass_to_def = FALSE;
            break;

        case IDM_NEW_RES:
            WdeCreateNewResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_DDE_CLEAR:
            WdeClearCurrentResource();
            pass_to_def = FALSE;
            break;

        case IDM_OPEN_RES:
            WdeOpenResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_SAVE_RES:
            WdeSaveResource( res_info, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_SAVEAS_RES:
            WdeSaveResource( res_info, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_DDE_UPDATE_PRJ:
            WdeUpdateDDEEditSession();
            break;

        case IDM_PASTEOBJECT:
            if( FMPasteValid() ) {
                ret = WdePassToEdit( message, wParam, lParam );
            }
            pass_to_def = FALSE;
            break;

        case IDM_CUTOBJECT:
        case IDM_COPYOBJECT:
            ret = WdePassToEdit( message, wParam, lParam );
            pass_to_def = FALSE;
            break;

        case IDM_SAME_WIDTH:
            WdeSameSize( R_RIGHT );
            pass_to_def = FALSE;
            break;

        case IDM_SAME_HEIGHT:
            WdeSameSize( R_BOTTOM );
            pass_to_def = FALSE;
            break;

        case IDM_SAME_SIZE:
            WdeSameSize( R_BOTTOM | R_RIGHT );
            pass_to_def = FALSE;
            break;

        case IDM_SIZETOTEXT:
            WdeHandleSizeToText();
            pass_to_def = FALSE;
            break;

        case IDM_GOTO_INFOBAR:
            WdeSetFocusToInfo();
            pass_to_def = FALSE;
            break;

        case IDM_GOTO_OBJECT:
            WdeHandleGotoCurrentObject();
            pass_to_def = FALSE;
            break;

        case IDM_DIALOG_RESTORE:
            WdeRestoreCurrentDialog();
            pass_to_def = FALSE;
            break;

        case IDM_TAB:
        case IDM_STAB:
            WdeHandleTabEvent( wp == IDM_TAB );
            pass_to_def = FALSE;
            break;

#if 0
        /* this strategy has been rejected in favor of the hide option */
        case IDM_REMOVE_DIALOG:
            WdeRemoveDialog( res_info );
            pass_to_def = FALSE;
            break;
#endif

        case IDM_HIDE_DIALOG:
            WdeHideCurrentDialog();
            pass_to_def = FALSE;
            break;

        case IDM_TEST_MODE:
            WdeHandleTestModeMenu( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_DIALOG_NEW:
            if( WdeCreateNewDialog( NULL, res_info->is32bit ) ) {
                WdeHandleGotoCurrentObject();
            }
            pass_to_def = FALSE;
            break;

        case IDM_DIALOG_SAVE:
        case IDM_DIALOG_SAVEAS:
        case IDM_DIALOG_SAVEINTO:
            WdeSaveCurrentDialog( wp );
            pass_to_def = FALSE;
            break;

        case IDM_SET_ORDER:
        case IDM_SET_TABS:
        case IDM_SET_GROUPS:
            WdeSetDialogMode( wp );
            pass_to_def = FALSE;
            break;

        case IDM_DEFINEOBJECT:
        case IDM_GEN_DEFINEOBJECT:
            if( !WdeDefineCurrentObject( wp ) ) {
                WdeWriteTrail( "WdeResWndProc: Define failed!" );
            }
            pass_to_def = FALSE;
            break;

        case IDM_MDI_CASCADE:
        case IDM_MDI_TILEV:
        case IDM_MDI_TILEH:
        case IDM_MDI_ARRANGE:
            WdeHandleMDIArrangeEvents( wp );
            pass_to_def = FALSE;
            break;

        case IDM_EXIT:
            /* clean up before we exit */
            PostMessage( hWinWdeMain, WM_CLOSE, 0, 0 );
            break;

        case IDM_SELCUST1:
        case IDM_SELCUST2:
            if( !WdeSetCurrentCustControl( wp - IDM_SELCUST1 ) ) {
                WdeWriteTrail( "WdeMainWndProc: WdeSetCurrentCustControl failed!" );
                WdeSetStatusByID( -1, WDE_SETFAILED );
            }
            pass_to_def = FALSE;
            break;

        case IDM_MS_CUSTOM:
            WdeLoadCustomLib( TRUE, FALSE );
            pass_to_def = FALSE;
            break;

#ifndef __NT__
        case IDM_BOR_CUSTOM:
            WdeLoadCustomLib( FALSE, FALSE );
            pass_to_def = FALSE;
            break;
#endif

        case IDM_LOADLIB:
            WdeLoadCustomLib( FALSE, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_WRITE_SYMBOLS:
            WdeResourceHashTableAction( res_info, WRITE_HASH );
            pass_to_def = FALSE;
            break;

        case IDM_LOAD_SYMBOLS:
            WdeResourceHashTableAction( res_info, LOAD_HASH );
            pass_to_def = FALSE;
            break;

        case IDM_VIEW_SYMBOLS:
            WdeResourceHashTableAction( res_info, VIEW_HASH );
            pass_to_def = FALSE;
            break;

        case IDM_SHOW_TOOLS:
            WdeHandleShowToolsMenu();
            pass_to_def = FALSE;
            break;

        case IDM_SHOW_RIBBON:
            WdeShowRibbon();
            pass_to_def = FALSE;
            break;

        case IDM_HELP:
            WdeHelpRoutine();
            pass_to_def = FALSE;
            break;

       case IDM_HELP_SEARCH:
            WdeHelpSearchRoutine();
            pass_to_def = FALSE;
            break;

       case IDM_HELP_ON_HELP:
            WdeHelpOnHelpRoutine();
            pass_to_def = FALSE;
            break;

       case IDM_ABOUT:
            ai.owner = hWnd;
            ai.inst = hInstWde;
            ai.name = AllocRCString( WDE_ABOUT_NAME );
            ai.version = AllocRCString( WDE_ABOUT_VERSION );
            ai.first_cr_year = "1984";
            ai.title = AllocRCString( WDE_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.version );
            FreeRCString( ai.title );
            pass_to_def = FALSE;
            break;
        }
        break;

    case WM_DESTROY:
        WWinHelp( hWinWdeMain, "resdlg.hlp", HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;

    case WDE_FATAL_EXIT:
        WdeFatalExit = TRUE;
        WdeQueryKillApp( TRUE );
        PostMessage( hWinWdeMain, WM_CLOSE, 0, 0 );
        break;

    case WM_ENDSESSION:
        if ( !wParam ) {
            WdeFatalExit = FALSE;
        }
        break;

    case WM_QUERYENDSESSION:
        ret = WdeQueryKillApp( FALSE );
        if( ret ) {
            WdeFatalExit = TRUE;
            pass_to_def = FALSE;
        }
        break;

    case WM_CLOSE:
        // this prevents the user from closing the editor during
        // DDE initialization
        if( !wParam && !EnableMenuInput ) {
            return( 0 );
        }
        /* clean up before we exit */
        WdeCleanupStarted = TRUE;
        if( wParam ) {  // wParam is non-zero if the DDE connection died
            WdeFatalExit = TRUE;
            WdeQueryKillApp( TRUE );
            wParam = 0;
        }
        if( !WdeCleanup( res_info, WdeFatalExit ) ) {
            WdeCleanupStarted = FALSE;
            pass_to_def = FALSE;
        }
    }

    if( pass_to_def ) {
        ret = DefFrameProc( hWnd, hWinWdeMDIClient, message, wParam, lParam );
    }
    return( ret );
}
Пример #15
0
//-----------------------------------------------------------------------------
// NAME: FrameProc(HWND, unsigned, WORD, LONG)
// DESCRIPTION:  Processes messages for the main window.
//-----------------------------------------------------------------------------
LRESULT CALLBACK FrameProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) 
    {   
        case WM_CREATE: // This happens when window is first created
        {
            CLIENTCREATESTRUCT ccs; 
 
            // Open the registry key we will be using
            g_reg.OpenKey(IMASM_REGISTRY_KEY);

            // Retrieve the handle to the window menu and assign the 
            // first child window identifier.  
            ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), 3); 
            ccs.idFirstChild = IDC_CHILDBASE; 
 
            // Create the MDI client window. 
            g_hMDIClient = CreateWindowEx(0,
                                        "MDICLIENT",
                                        (LPCTSTR)NULL,
                                        WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
                                        CW_USEDEFAULT,
                                        CW_USEDEFAULT,
                                        CW_USEDEFAULT,
                                        CW_USEDEFAULT,
                                        hWnd,
                                        (HMENU)IDC_CLIENT,
                                        g_hInst,
                                        (LPVOID)&ccs);  
            ShowWindow(g_hMDIClient, SW_SHOW); 

            // Create the file pane window
            g_pFP = new FilePane(hWnd);
    
            // Create the status bar
            g_hStatBar = CreateWindowEx(    0,
                                            STATUSCLASSNAME,
                                            NULL,
                                            WS_VISIBLE | WS_CHILD | SBARS_SIZEGRIP,
                                            CW_USEDEFAULT,
                                            CW_USEDEFAULT,
                                            CW_USEDEFAULT,
                                            CW_USEDEFAULT,
                                            hWnd,
                                            (HMENU)IDC_STATUS,
                                            g_hInst,
                                            0);

            CreateToolbar(hWnd);
    
            if (g_bAutoUpdate)
            {
                SendMessage(g_hToolBar, TB_SETSTATE, (WPARAM)IDC_AUTO, (LPARAM)(TBSTATE_ENABLED | TBSTATE_CHECKED));
            }

            // Fill up the popup structure
            HMENU hMenu = GetMenu(hWnd);
            HMENU hFile = GetSubMenu(hMenu, 0);
            HMENU hFormat = GetSubMenu(hMenu, 1);
            HMENU hProject = GetSubMenu(hMenu, 2);
            HMENU hWindow = GetSubMenu(hMenu, 3);
            HMENU hHelp = GetSubMenu(hMenu, 4);

            g_aPopup[0].hMenu = hMenu;
            g_aPopup[0].uiString = IDS_FILE_MENU;
            g_aPopup[1].hMenu = hFile;
            g_aPopup[1].uiString = IDS_FILE_MENU;
            g_aPopup[2].hMenu = hFormat;
            g_aPopup[2].uiString = IDS_FORMAT_MENU;
            g_aPopup[3].hMenu = hProject;
            g_aPopup[3].uiString = IDS_PROJECT_MENU;
            g_aPopup[4].hMenu = hWindow;
            g_aPopup[4].uiString = IDS_WINDOW_MENU;
            g_aPopup[5].hMenu = hHelp;
            g_aPopup[5].uiString = IDS_HELP_MENU;
            g_aPopup[6].hMenu = 0;
            g_aPopup[6].uiString = 0;
            
            return 0;
        }// WM_CREATE

        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDC_NEW:
                    HandleIDC_NEW(g_hMDIClient);
                    break;
                    
                case IDC_OPEN:
                    HandleIDC_OPEN(g_hMDIClient);
                    break;

                case IDC_OPENPROJECT:
                    HandleIDC_OPENPROJECT(g_hMDIClient, g_pFP);
                    break;

                case IDC_SAVEAS:
                    if (HandleIDC_SAVEAS(g_hCurChild) == 0)
                    {
                        break;
                    }
                    // FALLTHROUGH:

                case IDC_SAVE:
                    HandleIDC_SAVE(g_hCurChild);
                    break;

                case IDC_FONT:
                    HandleIDC_FONT(g_hMDIClient);
                    break;

                case IDC_EXIT:
                    PostMessage(hWnd, WM_CLOSE, 0, 0);
                    break;

                case IDC_ABOUT:
                    DialogBoxParam( g_hInst,
                                    MAKEINTRESOURCE(IDD_ABOUT),
                                    hWnd,
                                    (DLGPROC)AboutProc,
                                    0);
                    break;

                case IDC_AUTO:
                {
                    DWORD dwState = SendMessage(g_hToolBar, TB_GETSTATE, (WPARAM)IDC_AUTO, 0);

                    if ((dwState & TBSTATE_CHECKED) != 0)
                    {
                        g_bAutoUpdate = true;
                        HighlightDoc(GetDlgItem(g_hCurChild, IDC_MAINRICHED));
                        SetTimer(hWnd, UPDATETIMER, 20000, NULL);
                    }
                    else
                    {
                        g_bAutoUpdate = false;
                        KillTimer(hWnd, UPDATETIMER);
                    }
                    break;
                }

                case IDC_PRECOMPILE:
                    HandleIDC_PRECOMPILE(g_hCurChild);
                    break;

                case IDC_CASCADE:
                    SendMessage(g_hMDIClient, WM_MDICASCADE, MDITILE_SKIPDISABLED, 0);
                    break;

                case IDC_TILEHORIZ:
                    SendMessage(g_hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL | MDITILE_SKIPDISABLED, 0);
                    break;
                
                case IDC_TILEVERT:
                    SendMessage(g_hMDIClient, WM_MDITILE, MDITILE_VERTICAL | MDITILE_SKIPDISABLED, 0);
                    break;

                case IDC_PROJECTNEW:
                    HandleIDC_PROJECTNEW(hWnd, g_pFP);
                    break;

                case IDC_PROJECTADDSOURCE:
                    HandleIDC_PROJECTADDSOURCE(hWnd, g_pFP);
                    break;

                case IDC_PROJECTADDINCLUDE:
                    HandleIDC_PROJECTADDINCLUDE(hWnd, g_pFP);
                    break;

                case IDC_PROJECTADDOTHER:
                    HandleIDC_PROJECTADDOTHER(hWnd, g_pFP);
                    break;

                case IDC_PROJECTREMOVE:
                    HandleIDC_PROJECTREMOVE(hWnd, g_pFP);
                    break;
            }
            break;

        case WM_NOTIFY: 
        {
            LPNMHDR pHdr = (LPNMHDR)lParam;

            switch (pHdr->code) 
            { 
                case TTN_GETDISPINFO: 
                { 
                    LPTOOLTIPTEXT lpttt; 

                    lpttt = (LPTOOLTIPTEXT)lParam; 
                    lpttt->hinst = g_hInst; 

                    // Specify the resource identifier of the descriptive 
                    // text for the given button. 
                    switch (lpttt->hdr.idFrom) 
                    { 
                        case IDC_NEW: 
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_NEW); 
                            break; 
                        case IDC_OPEN: 
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_OPEN); 
                            break; 
                        case IDC_OPENPROJECT: 
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_OPENPROJECT); 
                            break; 
                        case IDC_SAVE: 
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_SAVE); 
                            break; 
                        case IDC_SAVEAS: 
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_SAVEAS); 
                            break; 
                        case IDC_AUTO: 
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_AUTO); 
                            break; 
                        case IDC_PRECOMPILE: 
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_PRECOMPILE); 
                            break; 
                    } 
                    break; 
                }

                case NM_DBLCLK:
                case NM_RETURN:
                {
                    char szPath[MAX_PATH];

                    if (g_pFP->GetCurSelPath(szPath, MAX_PATH))
                    {
                        LoadFileIntoNewWindow(szPath);
                    }
                    break;
                }

                case TVN_KEYDOWN:
                {
                    NMTVKEYDOWN *pKD;

                    pKD = (NMTVKEYDOWN *)lParam;

                    if (pKD->wVKey == VK_DELETE)
                    {
                        g_pFP->RemoveSelected();
                    }
                    break;
                }
                
                default: 
                    break; 
            } 
            break;
        }

        case WM_MENUSELECT:
        {
            UINT uFlags = (UINT)HIWORD(wParam);
            HMENU hMain = NULL;
            UINT i = 0;

            if (uFlags & MF_SYSMENU) // Handle non-system popup menus
            {
                MenuHelp(WM_MENUSELECT, wParam, lParam, NULL, g_hInst, g_hStatBar, &i);
            }
            else if (uFlags & MF_POPUP)
            {
                MenuHelp(WM_MENUSELECT, wParam, lParam, GetMenu(hWnd), g_hInst, g_hStatBar, (UINT *)g_aPopup);
            }
            else
            {
                for (i = 1; i < iNumMenus; i++)
                {
                    if ((HMENU)lParam == g_aPopup[i].hMenu)
                    {
                        MenuHelp(WM_MENUSELECT, wParam, lParam, GetMenu(hWnd), g_hInst, g_hStatBar, (LPUINT)&g_aPopup[i].uiString);
                        break;
                    }
                }               
            }

            

            return 0;
        }

        case WM_CLOSE:
            DestroyChildren(g_hMDIClient);
            DestroyWindow(hWnd);
            break;
        
        case WM_SIZE:  // Get size of client
        {
            int iClientX = LOWORD(lParam);
            int iClientY = HIWORD(lParam);

            SendMessage(g_hToolBar, TB_AUTOSIZE, 0, 0);
            
            int aiParts[] = {iClientX - 210, iClientX - 110, iClientX - 80, iClientX - 50, iClientX - 20};
            SendMessage(g_hStatBar, SB_SETPARTS, (WPARAM)5, (LPARAM)aiParts);
            SendMessage(g_hStatBar, WM_SIZE, 0, 0);
            UpdateStatusBar(g_hCurChild);
            
            RECT rc;

            GetWindowRect(g_hToolBar, &rc);

            int cyTool = rc.bottom - rc.top;

            GetWindowRect(g_hStatBar, &rc);

            int cyStat = rc.bottom - rc.top;

            // Now resize the file pane
            int cxFilePane = iClientX / 5;
            g_pFP->Resize(0, cyTool, cxFilePane, iClientY - cyTool - cyStat);           

            // And resize the MDI Client window
            MoveWindow(g_hMDIClient, cxFilePane, cyTool, iClientX - cxFilePane, iClientY - cyTool - cyStat, TRUE);              
            
            // Do this on the first WM_SIZE message so the window is sized properly
            if (*g_szCmdLineFile != NUL)
            {   
                LoadFileIntoNewWindow(g_szCmdLineFile);
                *g_szCmdLineFile = NUL;
            }

            return 0; // WM_SIZE
        }
        
        case WM_DESTROY:            
            if (g_pFP)
            {
                delete g_pFP;
            }

            DoExitProcessing(hWnd);
            PostQuitMessage(0);         
            break; // WM_DESTROY

        default:    // Otherwise, let Windows process message       
            break;
   }// end switch

   return DefFrameProc(hWnd, g_hMDIClient, message, wParam, lParam);
}
Пример #16
0
LRESULT 
CALLBACK
CMainWindow::WindowProc(
    HWND   hWnd,
    UINT   uMsg,
    WPARAM wParam,
    LPARAM lParam
)
{
    CMainWindow *that = (CMainWindow *) GetWindowLongPtr(hWnd, GWLP_USERDATA);

    switch (uMsg)
    {
        case WM_CREATE:
        {
            LPCREATESTRUCT pcs = (LPCREATESTRUCT) lParam;

            that = (CMainWindow *) pcs->lpCreateParams;

            // Create the MDI client window that will handle the MDI child windows

            CLIENTCREATESTRUCT ccs = { 0 };

            ccs.hWindowMenu  = GetSubMenu(GetMenu(hWnd), WINDOW_MENU_POSITION);
            ccs.idFirstChild = FIRST_MDI_CHILD;

            that->m_hMDIClient = CreateWindowEx(
                0,
                _T("MDICLIENT"), 
                0, 
                WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE, 
                0,
                0,
                0, 
                0,
                hWnd,
                NULL, 
                g_hInstance, 
                &ccs
            );

            if (that->m_hMDIClient == NULL)
            {
                return -1;
            }

            that->AddRef();

            SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) that);

            break;
        }

        case WM_DESTROY:
        {
            SetWindowLongPtr(hWnd, GWLP_USERDATA, NULL);

            that->Release();

            PostQuitMessage(0);

            break;
        }

        case WM_SETCURSOR:
        {
            if (that->m_bDisplayWaitCursor)
            {
                SetCursor(LoadCursor(NULL, IDC_WAIT));

                return TRUE;
            }

            break;
        }

        case WM_INITMENU:
        {
            if (that->m_pEventCallback != NULL)
            {
                LONG nNumDevices = that->m_pEventCallback->GetNumDevices();

                UINT uEnable = nNumDevices > 0 ? MF_ENABLED : MF_GRAYED;

                EnableMenuItem((HMENU) wParam, ID_FILE_FROM_SCANNER_OR_CAMERA, uEnable);
            }

            break;
        }

        case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
                case ID_FILE_FROM_SCANNER_OR_CAMERA:
                {
                    that->OnFromScannerOrCamera();
                    break;
                }

                case ID_FILE_EXIT:
                {
                    DestroyWindow(hWnd);
                    break;
                }

                case ID_WINDOW_CASCADE:
                {
                    SendMessage(that->m_hMDIClient, WM_MDICASCADE, 0, 0);
                    break;
                }

                case ID_WINDOW_TILE_HORIZONTALLY:
                {
                    SendMessage(that->m_hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0);
                    break;
                }

                case ID_WINDOW_TILE_VERTICALLY:
                {
                    SendMessage(that->m_hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0);
                    break;
                }

                case ID_WINDOW_ARRANGE_ICONS:
                {
                    SendMessage(that->m_hMDIClient, WM_MDIICONARRANGE, 0, 0);
                    break;
                }

                case ID_HELP_ABOUT:
                {
                    TCHAR szAppName[DEFAULT_STRING_SIZE] = _T("");

	                LoadString(g_hInstance, IDS_APP_NAME, szAppName, COUNTOF(szAppName));

                    ShellAbout(hWnd, szAppName, NULL, NULL);

                    break;
                }
            }

            break;
        }
    }

    return DefFrameProc(
        hWnd,
        that == NULL ? NULL : that->m_hMDIClient,
        uMsg,
        wParam,
        lParam
    );
}
Пример #17
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_CREATE:
			{
				//Create Toolbar
				HWND hTool;
				TBBUTTON tbb[3];
				TBADDBITMAP tbab;

				hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 100, 100,
						hwnd, (HMENU)IDC_MAIN_TOOL, GetModuleHandle(NULL), NULL);
				if (hTool == NULL)
					MessageBox(hwnd, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);

				//Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility.
				SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);

				tbab.hInst = HINST_COMMCTRL;
				tbab.nID = IDB_STD_SMALL_COLOR;
				SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);

				ZeroMemory(tbb, sizeof(tbb));
				tbb[0].iBitmap = STD_FILENEW;
				tbb[0].fsState = TBSTATE_ENABLED;
				tbb[0].fsStyle = TBSTYLE_BUTTON;
				tbb[0].idCommand = ID_FILE_NEW;

				tbb[1].iBitmap = STD_FILEOPEN;
				tbb[1].fsState = TBSTATE_ENABLED;
				tbb[1].fsStyle = TBSTYLE_BUTTON;
				tbb[1].idCommand = ID_FILE_OPEN;

				tbb[2].iBitmap = STD_FILESAVE;
				tbb[2].fsState = TBSTATE_ENABLED;
				tbb[2].fsStyle = TBSTYLE_BUTTON;
				tbb[2].idCommand = ID_FILE_SAVEAS;

				SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);

				//Create Status bar
				HWND hStatus;
				int statwidths[] = {100, -1};

				hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL,
						WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0,
						hwnd, (HMENU)IDC_MAIN_STATUS, GetModuleHandle(NULL), NULL);

				SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
				SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Hi there :)");

				//Create Client Window
				CLIENTCREATESTRUCT ccs;

				ccs.hWindowMenu = GetSubMenu(GetMenu(hwnd), 2);
				ccs.idFirstChild = ID_MDI_FIRSTCHILD;

				g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient", NULL, 
						WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
						CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
						hwnd, (HMENU)IDC_MAIN_MDI, GetModuleHandle(NULL), (LPVOID)&ccs);

				break;
			}
		case WM_SIZE:
			{
				//Size toolbar and get height
				HWND hTool;
				RECT rcTool;
				int iToolHeight;

				hTool = GetDlgItem(hwnd, IDC_MAIN_TOOL);
				SendMessage(hTool, TB_AUTOSIZE, 0, 0);

				GetWindowRect(hTool, &rcTool);
				iToolHeight = rcTool.bottom - rcTool.top;

				//Size status bar and get height
				HWND hStatus;
				RECT rcStatus;
				int iStatusHeight;

				hStatus = GetDlgItem(hwnd, IDC_MAIN_STATUS);
				SendMessage(hStatus, WM_SIZE, 0, 0);

				GetWindowRect(hStatus, &rcStatus);
				iStatusHeight = rcStatus.bottom - rcStatus.top;

				//Calculata remaining height and size client window
				HWND hMDI;
				int iMDIHeight;
				RECT rcClient;

				GetClientRect(hwnd, &rcClient);
				iMDIHeight = rcClient.bottom - iToolHeight - iStatusHeight;
				hMDI = GetDlgItem(hwnd, IDC_MAIN_MDI);
				SetWindowPos(hMDI, NULL, 0, iToolHeight, rcClient.right, iMDIHeight, SWP_NOZORDER);

				break;
			}
		case WM_MDIACTIVATE:
			{
				HMENU hMenu, hFileMenu;
				UINT EnableFlag;

				hMenu = GetMenu(g_hMainWindow);
				if (hwnd == (HWND)lParam)
					EnableFlag = MF_ENABLED;
				else
					EnableFlag = MF_GRAYED;

				EnableMenuItem(hMenu, 1, MF_BYPOSITION | EnableFlag);
				EnableMenuItem(hMenu, 2, MF_BYPOSITION | EnableFlag);

				hFileMenu = GetSubMenu(hMenu, 0);
				EnableMenuItem(hFileMenu, ID_FILE_SAVEAS, MF_BYCOMMAND | EnableFlag);
				EnableMenuItem(hFileMenu, ID_FILE_CLOSE, MF_BYCOMMAND | EnableFlag);
				EnableMenuItem(hFileMenu, ID_FILE_CLOSEALL, MF_BYCOMMAND | EnableFlag);

				DrawMenuBar(g_hMainWindow);

				break;
			}
		case WM_COMMAND:
			switch (LOWORD(wParam))
			{
				case ID_FILE_EXIT:
					PostMessage(hwnd, WM_CLOSE, 0, 0);
					break;
				case ID_FILE_NEW:
					CreateNewMDIChild(g_hMDIClient);
					break;
				case ID_FILE_OPEN:
					{
						HWND hChild = CreateNewMDIChild(g_hMDIClient);
						if (hChild)
							DoFileOpen(hChild);
						break;
					}
				case ID_FILE_CLOSE:
					{
						HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE, 0, 0);
						if (hChild)
							SendMessage(hChild, WM_CLOSE, 0, 0);
						break;
					}
				case ID_FILE_SAVEAS:
					{
						HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE, 0, 0);
						if (hChild)
							DoFileSave(hChild);
						break;
					}
				case ID_WINDOW_TILE:
					SendMessage(g_hMDIClient, WM_MDITILE, 0, 0);
					break;
				case ID_WINDOW_CASCADE:
					SendMessage(g_hMDIClient, WM_MDICASCADE, 0, 0);
					break;

				default:
					{
						if (LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
							DefFrameProc(hwnd, g_hMDIClient, msg, wParam, lParam);
						else
						{
							HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE, 0, 0);
							if (hChild)
								SendMessage(hChild, WM_COMMAND, wParam, lParam);
						}
					}
			}
			break;
		case WM_CLOSE:
			DestroyWindow(hwnd);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		default:
			return DefFrameProc(hwnd, g_hMDIClient, msg, wParam, lParam);
	}
	return 0;
}
Пример #18
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	static HWND last_focus=0;
	if(FALSE)
	//if(msg!=WM_MOUSEFIRST&&msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE&&msg!=WM_NOTIFY)
	if(msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE&&msg!=WM_MOUSEMOVE&&msg!=WM_NCMOUSEMOVE)
	{
		static DWORD tick=0;
		if((GetTickCount()-tick)>500)
			printf("--\n");
		print_msg(msg,lparam,wparam,hwnd);
		tick=GetTickCount();
	}
    switch(msg)
    {
	case WM_MENUSELECT:
		break;
	case WM_CREATE:
		{
			RECT rect={0};
			extern int keep_closed,trim_trailing,left_justify;
			get_ini_value("SETTINGS","KEEP_CLOSED",&keep_closed);
			get_ini_value("SETTINGS","TRIM_TRAILING",&trim_trailing);
			get_ini_value("SETTINGS","LEFT_JUSTIFY",&left_justify);
			load_icon(hwnd);

			load_window_size(hwnd,"MAIN_WINDOW");

			GetClientRect(hwnd,&rect);
			get_ini_value("SETTINGS","TREE_WIDTH",&tree_width);
			if(tree_width>rect.right-10 || tree_width<10){
				tree_width=rect.right/4;
				if(tree_width<12)
					tree_width=12;
			}

			ghmdiclient=create_mdiclient(hwnd,ghmenu,ghinstance);
			ghdbview=create_dbview(hwnd,ghinstance);
			ghstatusbar=CreateStatusWindow(WS_CHILD|WS_VISIBLE,"ready",hwnd,IDC_STATUS);
			create_status_bar_parts(hwnd,ghstatusbar);

			resize_main_window(hwnd,tree_width);
		}
		break;
	case WM_DROPFILES:
		process_drop(hwnd,wparam);
		break;
	case WM_COPYDATA:
		if(lparam!=0){
			COPYDATASTRUCT *cd=lparam;
			process_cmd_line(cd->lpData);
		}
		break;
	case WM_USER:
		debug_window_focus(lparam,"WM_USER");
		switch(wparam){
		case IDC_TREEVIEW:
			if(lparam!=0)
				SetFocus(lparam);
			break;
		case IDC_MDI_LISTVIEW:
			if(lparam!=0){
				last_focus=lparam;
				SetFocus(lparam);
			}
			break;
		case IDC_LV_EDIT:
			if(lparam!=0)
				last_focus=lparam;
			break;
		}
		break;
	case WM_USER+1:
		debug_window_focus(last_focus,"WMUSER+1");
		if(last_focus!=0)
			SetFocus(last_focus);
		break;
	case WM_NCACTIVATE:
		debug_window_focus(last_focus,"NCACTIVATE wparam=%08X",wparam);
		if(wparam==0){
			last_focus=GetFocus();
		}
		else{
			PostMessage(hwnd,WM_USER+1,0,0);
		}
		break;
	case WM_ACTIVATEAPP: //close any tooltip on app switch
		debug_window_focus(last_focus,"ACTIVATEAPP wparam=%08X",wparam);
		if(wparam){
			PostMessage(hwnd,WM_USER+1,0,0);
		}
		break;
	case WM_KILLFOCUS:
	case WM_RBUTTONDOWN:
	case WM_LBUTTONUP:
		if(main_drag){
			ReleaseCapture();
			main_drag=FALSE;
			write_ini_value("SETTINGS","TREE_WIDTH",tree_width);
		}
		break;
	case WM_LBUTTONDOWN:
		{
			int x=LOWORD(lparam);
			if(x>=(tree_width-10) && x<(tree_width+10)){
				SetCapture(hwnd);
				SetCursor(LoadCursor(NULL,IDC_SIZEWE));
				main_drag=TRUE;
			}
		}
		break;
	case WM_MOUSEFIRST:
		{
			int x=LOWORD(lparam);
			if(x>=(tree_width-10) && x<(tree_width+10))
				SetCursor(LoadCursor(NULL,IDC_SIZEWE));
			if(main_drag){
				RECT rect;
				GetClientRect(ghmainframe,&rect);
				if(x>10 && x<rect.right-10){
					tree_width=x;
					resize_main_window(hwnd,tree_width);
				}
			}
		}
		break;
	case WM_COMMAND:
		switch(LOWORD(wparam)){
		case IDM_OPEN:
			if((GetKeyState(VK_SHIFT)&0x8000) || GetKeyState(VK_CONTROL)&0x8000)
				task_open_db("");
			else{
				if(does_key_exist("SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources","Journal"))
					task_open_db("UID=dba;PWD=sql;DSN=Journal");
				else
					task_open_db("");
			}
			break;
		case IDM_CLOSE:
			{
			HANDLE hroot=0;
			if(tree_find_focused_root(&hroot)){
				char str[MAX_PATH]={0};
				tree_get_db_table(hroot,str,sizeof(str),0,0,0);
				if(str[0]!=0){
					set_status_bar_text(ghstatusbar,0,"closing %s",str);
					task_close_db(str);
				}
			}
			else
				set_status_bar_text(ghstatusbar,0,"select a DB");
			}
			break;
		case IDM_SETTINGS:
			DialogBox(ghinstance,MAKEINTRESOURCE(IDD_SETTINGS),hwnd,settings_proc);
			break;
		case IDM_RECENT:
			DialogBox(ghinstance,MAKEINTRESOURCE(IDD_RECENT),hwnd,recent_proc);
			break;
		case IDM_STOP_THREAD:
			{
				int click=MessageBox(hwnd,"Are you sure you want to terminate the task?","Warning",MB_OKCANCEL|MB_SYSTEMMODAL);
				if(click==IDOK){
					terminate_worker_thread();
					stop_thread_menu(FALSE);
				}
			}
			break;
		case IDM_QUERY:
			task_new_query();
			break;
		case IDC_EXECUTE_SQL:
			task_execute_query(NULL);
			break;
		case IDM_TILE_DIALOG:
			tile_select_dialog(hwnd);
			break;
		case IDM_WINDOW_TILE:
			mdi_tile_windows_vert();
			break;
		case IDM_WINDOW_CASCADE:
			mdi_cascade_win_vert();
			break;
		case IDM_WINDOW_LRTILE:
			mdi_tile_windows_horo();
			break;
		case IDM_REFRESH_ALL:
			refresh_all_dialog(hwnd);
			break;
		case IDM_REORDER:
			reorder_win_dialog(hwnd);
			break;
		}
		break;
	case WM_SIZE:
		resize_main_window(hwnd,tree_width);
		create_status_bar_parts(ghmainframe,ghstatusbar);
		return 0;
		break;
	case WM_QUERYENDSESSION:
		return 1; //ok to end session
		break;
	case WM_ENDSESSION:
		if(wparam){
			if(!(GetKeyState(VK_SHIFT)&0x8000))
				save_window_size(hwnd,"MAIN_WINDOW");
		}
		return 0;
	case WM_CLOSE:
        break;
	case WM_DESTROY:
		if(!(GetKeyState(VK_SHIFT)&0x8000))
			save_window_size(hwnd,"MAIN_WINDOW");
		PostQuitMessage(0);
        break;
    }
	return DefFrameProc(hwnd, ghmdiclient, msg, wparam, lparam);
}
Пример #19
0
LRESULT FrameWindow::FrameWndProc(HWND hWndFrame, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    FrameWindow* frame = (FrameWindow*)GetProp(hWndFrame, L"FrameWindowPointer");

    switch(uMsg)
    {
    case WM_NCCREATE:
        if(NULL == frame)
        {
            frame = new FrameWindow(hWndFrame);
            SetProp(hWndFrame, L"FrameWindowPointer", frame);
        }
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDM_ABOUT:
            DialogBox((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUTBOX), hWndFrame, AboutDialog::About);
            break;

		case IDM_NEW:
			frame->NewDocument(wParam, lParam);
			break;

        case IDM_EXIT:
            DestroyWindow(hWndFrame);
            break;

        default:
            if(frame)
                return DefFrameProc(hWndFrame, frame->hClientWnd, uMsg, wParam, lParam);
	        else
		        return DefFrameProc(hWndFrame, NULL, uMsg, wParam, lParam);
        }
        break;
        
    case WM_CREATE:
        return frame->Create(wParam, lParam);

    case WM_NCDESTROY:
        RemoveProp(hWndFrame,  L"FrameWindowPointer");  // remove the C++ object pointer from the property list
        if(frame)
            delete frame;
        PostQuitMessage(0);
        return 0;

	case WM_SIZE:
		return frame->Size(wParam, lParam);

    default:
       if(frame)
           return DefFrameProc(hWndFrame, frame->hClientWnd, uMsg, wParam, lParam);
	   else
		   return DefFrameProc(hWndFrame, NULL, uMsg, wParam, lParam);
    }

       if(frame)
           return DefFrameProc(hWndFrame, frame->hClientWnd, uMsg, wParam, lParam);
	   else
		   return DefFrameProc(hWndFrame, NULL, uMsg, wParam, lParam);
}
Пример #20
0
static LRESULT CALLBACK
ConsoleMainFrameWndProc(IN HWND hwnd,
                        IN UINT uMsg,
                        IN WPARAM wParam,
                        IN LPARAM lParam)
{
    PCONSOLE_MAINFRAME_WND Info;

    Info = (PCONSOLE_MAINFRAME_WND)GetWindowLongPtr(hwnd,
                                                    0);

    switch (uMsg)
    {
        case WM_CREATE:
            return FrameOnCreate(hwnd,
                                 lParam);

        case WM_COMMAND:
            FrameOnCommand(hwnd,
                           uMsg,
                           wParam,
                           lParam);
            break;

        case WM_SIZE:
            FrameOnSize(hwnd,
                        LOWORD(lParam),
                        HIWORD(lParam));
            break;

        case WM_CLOSE:
            DestroyWindow(hwnd);
            break;

        case WM_DESTROY:
            if (Info != NULL)
            {
                SetMenu(Info->hwnd,
                        NULL);

                if (Info->hMenuConsoleSmall != NULL)
                {
                    DestroyMenu(Info->hMenuConsoleSmall);
                    Info->hMenuConsoleSmall = NULL;
                }

                if (Info->hMenuConsoleLarge != NULL)
                {
                    DestroyMenu(Info->hMenuConsoleLarge);
                    Info->hMenuConsoleLarge = NULL;
                }

                HeapFree(hAppHeap,
                         0,
                         Info);
            }

            PostQuitMessage(0);
            break;

        case WM_USER_CLOSE_CHILD:
            Info->nConsoleCount--;
            if (Info->nConsoleCount == 0)
            {
                SetMenu(Info->hwnd,
                        Info->hMenuConsoleSmall);
            }
            break;

        default:
            return DefFrameProc(hwnd,
                                hwndMDIClient,
                                uMsg,
                                wParam,
                                lParam);
    }

    return 0;
}
Пример #21
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 回调函数
LRESULT CALLBACK CMainWnd::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CChildWnd *pWnd;
	TCHAR tzTemp[MAX_PATH];

	switch (uMsg)
	{
	case WM_CREATE:
		// 窗口被创建
		m_hWnd = hWnd;
		m_hMenu = GetMenu(m_hWnd);
		OnCreate();
		break;

	case WM_SIZE:
		// 尺寸改变
		OnSize(wParam, lParam);
		return 0;

	case WM_WINDOWPOSCHANGED:
		// 位置改变
		for (pWnd = CChildWnd::m_pHead; pWnd; pWnd = pWnd->m_pNext)
		{
			if (pWnd->m_hWnd)
			{
				pWnd->SetDrawRect();
			}
		}
		break;

	case WM_INITMENUPOPUP:
		// 弹出菜单初始化
		OnMenuPopup(wParam, lParam);
		break;

	case WM_MENUSELECT:
		// 菜单项被选择
		OnMenuSelect(LOWORD(wParam));
		break;

	case WM_EXITMENULOOP:
		// 退出菜单循环
		CClientWnd::SetStatusText(LNG_Ready);
		break;

	case WM_COMMAND:
		// 命令处理
		OnCommand(wParam, lParam);
		break;

	case WM_COPYDATA:
		// 本程序的其它实例通知打开文件
		if (((PCOPYDATASTRUCT) lParam)->dwData == IDM_File_Open)
		{
			static TCHAR s_tzFileName[MAX_PATH];

			lstrcpyn(s_tzFileName, (PTSTR) ((PCOPYDATASTRUCT) lParam)->lpData, MAX_PATH);
			PostMessage(m_hWnd, WM_COMMAND, IDM_File_Open, (LPARAM) s_tzFileName);
		}
		break;

	case WM_HOTKEY:
		// 热键消息
		if ((m_hWnd != GetForegroundWindow()) && (wParam == IDC_TrayIcon))
		{
			OnTrayIcon(FALSE);
		}
		break;

	case WM_DROPFILES:
		// 拖动文件
		DragQueryFile((HDROP) wParam, 0, tzTemp, MAX_PATH);
		DragFinish((HDROP) wParam);
		OnFileOpen(tzTemp);
		break;

	case WM_HELP:
		// 帮助
		OnCommand(IDM_Help_Content);
		break;

	case WM_DESTROY:
		// 窗口被销毁
		OnDestroy();
		break;
	}

	return DefFrameProc(hWnd, CClientWnd::m_hWnd, uMsg, wParam, lParam);
}
Пример #22
0
//
// Frame_Procedure
//
// This window procedure handles messages that are sent to the frame
// window (the window for the entire application).
//
LRESULT CALLBACK Frame_Procedure(
  HWND   Frame_Window,
  UINT   Message,
  WPARAM wParam,
  LPARAM lParam
  )
  {
    static HWND Topic_Window;
    static HWND Client_Window;

    try {
              
      switch (Message) {

        case WM_CREATE: {
            Tracer(2, "Processing WM_CREATE in the MDI frame window.");

            // Create the image list that I need.
            Image_Handle = ImageList_Create(16, 16, ILC_COLOR4 | ILC_MASK, 2, 0);
            if (Image_Handle == 0)
              throw spica::Win32::API_Error("Can't create image list");

            // Get the icon resources from the executable file. Note
            // that under Win32 we don't have to explicitly destory
            // these resources.
            //
            HICON UnChecked = static_cast<HICON>(
              LoadImage(Global::Get_Instance(), MAKEINTRESOURCE(UNCHECKED_ICON), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
            if (UnChecked == 0)
              throw spica::Win32::API_Error("Can't load UNCHECKED_ICON");

            HICON Checked = static_cast<HICON>(
              LoadImage(Global::Get_Instance(), MAKEINTRESOURCE(CHECKED_ICON), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
            if (Checked == 0)
              throw spica::Win32::API_Error("Can't load CHECKED_ICON");

            // Add the images to the image list.
            if (ImageList_AddIcon(Image_Handle, UnChecked) == -1)
              throw spica::Win32::API_Error("Can't add UNCHECKED_ICON to the image list");
            if (ImageList_AddIcon(Image_Handle, Checked) == -1)
              throw spica::Win32::API_Error("Can't add CHECKED_ICON to the image list");

            // Create the MDI client window.
            CLIENTCREATESTRUCT Client_Create;
            RECT               Frame_Rect;

            Client_Create.hWindowMenu  = 0;
            Client_Create.idFirstChild = 100;

            // Create the MDI client window.
            Client_Window = CreateWindow(
	      "MDICLIENT",
	      0,
	      WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
	      0, 0, 0, 0,
	      Frame_Window,
	      reinterpret_cast<HMENU>(1),
	      Global::Get_Instance(),
	      reinterpret_cast<LPVOID>(&Client_Create)
	    );
            if (Client_Window == 0)
              throw spica::Win32::API_Error("Can't create the MDI client window");

            Tracer(2, "Finished creating the MDI client window.");

            // Create the topic window.	 
            GetClientRect(Frame_Window, &Frame_Rect);
            Topic_Window = CreateMDIWindow(
              const_cast<char *>(Topic_ClassName),
              "Topic Window", 
              WS_CHILD | WS_VISIBLE,
              0, 0, Frame_Rect.right/2, Frame_Rect.bottom, 
              Client_Window,
              Global::Get_Instance(),
              0
            );
            if (Topic_Window == 0)
              throw spica::Win32::API_Error("Can't create the topic window");

            Tracer(2, "Finished creating the topic window.");
          }
          return 0;

        // A menu item was selected.
        case WM_COMMAND:
          switch (wParam) {

            case MENU_CONFIGURE: {
                Tracer(2, "Selected 'File|Configure' menu item.");
                DialogBox(Global::Get_Instance(), MAKEINTRESOURCE(CONFIG_DIALOG), Frame_Window, Config_Dialog);
              }
              return 0;

            case MENU_EXIT: {
                Tracer(2, "Selected 'File|Exit' menu item.");
                DestroyWindow(Frame_Window);
              }
              return 0;

            case MENU_POST: {
                Tracer(2, "Selected 'Topic|Post' menu item.");

                DialogBox(Global::Get_Instance(), MAKEINTRESOURCE(POST_DIALOG), Frame_Window, Post_Dialog);
              }
              return 0;

            case MENU_MARKALL: {
                Tracer(2, "Selected 'Topic|Mark All As Read' menu item.");
                Current_Topic->Mark_All(History_Database);
                SendMessage(Topic_Window, WM_USER, 0, 0);
              }
              return 0;

            case MENU_MARKSELECTED: {
                Tracer(2, "Selected 'Topic|Mark Selected As Read' menu item.");
                MessageBox(Frame_Window, "Not Implemented", "Sorry", MB_ICONEXCLAMATION);
              }
              return 0;

            case MENU_FOLLOWUP: {
                Tracer(2, "Selected 'Notice|Followup' menu item.");
                MessageBox(Frame_Window, "Not Implemented", "Sorry", MB_ICONEXCLAMATION);
              }
              return 0;

            case MENU_DEBUG: {
                Tracer(2, "Selected 'Debug' menu item.");
                spica::Win32::create_debugWindow();
              }
              return 0;

            case MENU_TILE: {
                Tracer(2, "Selected 'Window|Tile' menu item.");
                SendMessage(Client_Window, WM_MDITILE, 0, 0);
              }
              return 0;

            case MENU_CASCADE: {
                Tracer(2, "Selected 'Window|Cascade' menu item.");
                SendMessage(Client_Window, WM_MDICASCADE, 0, 0);
              }
              return 0;

            case MENU_ARRANGE: {
                Tracer(2, "Selected 'Window|Arrange' menu item.");
                SendMessage(Client_Window, WM_MDIICONARRANGE, 0, 0);
              }
              return 0;

            case MENU_HELP: {
                Tracer(2, "Selected 'Help' menu item.");
                MessageBox(Frame_Window, "Not Implemented", "Sorry", MB_ICONEXCLAMATION);
              }
              return 0;

            default: {
              Tracer(2, "Other WM_COMMAND seen. Sending to active MDI child window.");
              HWND MDIChild_Window =
                reinterpret_cast<HWND>(SendMessage(Client_Window, WM_MDIGETACTIVE, 0, 0));
              if (IsWindow(MDIChild_Window))
                SendMessage(MDIChild_Window, WM_COMMAND, wParam, lParam);
              break;
            }	
          }
          break;

        // The user is trying to close the application (or shut down Windows).
        case WM_QUERYENDSESSION:
        case WM_CLOSE:

          // Try to close all the children.
          EnumChildWindows(Client_Window, Close_Childs, 0);

          // If it didn't work, return 0. Otherwise call DefFrameProc().
          if (GetWindow(Client_Window, GW_CHILD) != 0) return 0;
          break;

        // The main window is being destroyed.
        case WM_DESTROY:
          ImageList_Destroy(Image_Handle);
          PostQuitMessage(0);
          return 0;
      
      }

    }
    catch (spica::Win32::API_Error We) {
      spica::Win32::notifystream Error_Message;

      Error_Message << "Exception caught in the frame window\r" << We.what() << ends;
      Error_Message.say(Frame_Window);
      return 0;
    }
    catch (...) {
      spica::Win32::notifystream Error_Message;

      Error_Message << "Unknown exception caught in the frame window" << ends;
      Error_Message.say(Frame_Window);
      return 0;
    }

    return DefFrameProc(Frame_Window, Client_Window, Message, wParam, lParam);
  }
Пример #23
0
static LRESULT CALLBACK
MainWndProc(HWND hwnd,
            UINT uMsg,
            WPARAM wParam,
            LPARAM lParam)
{
    PMAIN_WND_INFO Info;
    LRESULT Ret = 0;
    static RECT wndOldPos;

    /* Get the window context */
    Info = (PMAIN_WND_INFO)GetWindowLongPtr(hwnd,
                                            GWLP_USERDATA);
    if (Info == NULL && uMsg != WM_CREATE)
    {
        goto HandleDefaultMessage;
    }

    switch (uMsg)
    {
        case WM_CREATE:
        {
            Info = (PMAIN_WND_INFO)(((LPCREATESTRUCT)lParam)->lpCreateParams);

            /* Initialize the main window context */
            Info->hSelf = hwnd;

            SetWindowLongPtr(hwnd,
                             GWLP_USERDATA,
                             (LONG_PTR)Info);

            InitMainWnd(Info);

            /* Show the window */
            ShowWindow(hwnd,
                       Info->nCmdShow);
            /* get the windows position */
            GetWindowRect(hwnd,
                          &wndOldPos);

            break;
        }

        case WM_SIZE:
        {
            MainWndResize(Info,
                          LOWORD(lParam),
                          HIWORD(lParam));
            /* NOTE - do *not* forward this message to DefFrameProc! Otherwise the MDI client
                      will attempt to resize itself */

            break;
        }

        case WM_MOVE:
        {

        }
        break;

        case WM_NOTIFY:
        {

                /* FIXME - handle other notifications */
            break;
        }

        case WM_COMMAND:
        {
            MainWndCommand(Info,
                           LOWORD(wParam),
                           (HWND)lParam);
            goto HandleDefaultMessage;
        }

        case WM_MENUSELECT:
        {
            if (Info->hStatus != NULL)
            {
                if (!MainWndMenuHint(Info,
                                     LOWORD(wParam),
                                     MainMenuHintTable,
                                     sizeof(MainMenuHintTable) / sizeof(MainMenuHintTable[0]),
                                     IDS_HINT_BLANK))
                {
                    MainWndMenuHint(Info,
                                    LOWORD(wParam),
                                    SystemMenuHintTable,
                                    sizeof(SystemMenuHintTable) / sizeof(SystemMenuHintTable[0]),
                                    IDS_HINT_BLANK);
                }
            }
            break;
        }

        case WM_ENTERMENULOOP:
        {
            Info->InMenuLoop = TRUE;
            UpdateMainStatusBar(Info);
            break;
        }

        case WM_EXITMENULOOP:
        {
            Info->InMenuLoop = FALSE;
            UpdateMainStatusBar(Info);
            break;
        }

        case WM_CLOSE:
        {
            DestroyWindow(hwnd);
            break;
        }

        case WM_ENABLE:
        {

            goto HandleDefaultMessage;
        }

        case WM_NCACTIVATE:
        {

            goto HandleDefaultMessage;
        }

        case WM_ACTIVATEAPP:
        {

            goto HandleDefaultMessage;
        }

        case WM_DESTROY:
        {
            DestroyMainWnd(Info);

            /* FIXME: set the windows position in registry*/
            //wndOldPos

            HeapFree(ProcessHeap,
                     0,
                     Info);
            SetWindowLongPtr(hwnd,
                             GWLP_USERDATA,
                             0);

            /* Break the message queue loop */
            PostQuitMessage(0);
            break;
        }

        default:
        {
HandleDefaultMessage:
            if (Info != NULL && Info->hMdiClient != NULL)
            {
                Ret = DefFrameProc(hwnd,
                                   Info->hMdiClient,
                                   uMsg,
                                   wParam,
                                   lParam);
            }
            else
            {
                Ret = DefWindowProc(hwnd,
                                    uMsg,
                                    wParam,
                                    lParam);
            }
            break;
        }
    }

    return Ret;
}
Пример #24
0
LRESULT MDIFrame::DefProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{
    return DefFrameProc(hWnd,hClient,Msg,wParam,lParam);
}
Пример #25
0
LONG APIENTRY FrameWndProc(
    HWND hwnd,
    UINT msg,
    UINT wParam,
    LONG lParam)
{
    CLIENTCREATESTRUCT ccs;
    char szT[80];
    HMENU hmenu;
    int i;

    switch (msg) {
    case WM_CREATE:
        /*
         * Add all the benchmark menu items to the benchmark menu.
         */
        hmenu = GetSubMenu(GetMenu(hwnd), 2);
        for (i = 0; i < gcbmi; i++) {
            wsprintf(szT, "&%c. %s", 'A' + (i%26), (LPSTR)gabmi[i].pszBenchTitle);
            if ((i > 0) && ((i%26) == 0))
                AppendMenu(hmenu, MF_MENUBREAK, 200, NULL);
            AppendMenu(hmenu, MF_STRING | MF_ENABLED, IDM_BENCHFIRST + i, szT);
            gabmi[i].usPerIteration = 0;
        }

        /*
         * Create the MDI client filling the client area
         */
        ccs.hWindowMenu = NULL;
        ccs.idFirstChild = 0;

        ghwndMDIClient = CreateWindow("mdiclient",
                NULL, WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
                0, 0, 0, 0, hwnd, (HMENU)0xCAC, ghinst, (LPSTR)&ccs);

        ShowWindow(ghwndMDIClient, SW_SHOW);
        break;

    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDM_ABOUT:
            DialogBox(ghinst, (LPSTR)IDD_ABOUT, hwnd, (DLGPROC)AboutDlgProc);
            break;

        case IDM_VIEWRESULTS:
            DialogBox(ghinst, (LPSTR)IDD_RESULTS, hwnd, (DLGPROC)ResultsDlgProc);
            break;

        case IDM_SAVERESULTS:
            SaveResults(hwnd);
            break;

        case IDM_ALL:
            gfAll = TRUE;
            for (gibmi = 0; gibmi < gcbmi; gibmi++) {
                gabmi[gibmi].pfnBenchmark(gabmi[gibmi].cIterations);
            }
            gfAll = FALSE;

            DialogBox(ghinst, (LPSTR)IDD_RESULTS, hwnd, (DLGPROC)ResultsDlgProc);
            break;

        case IDM_PROFILEALL:
            /*
             * We don't want a million iterations of these guys when we're
             * profiling because it takes too long.  Each benchmark will
             * iterate 5 times.
             */
            gfAll = TRUE;
            for (gibmi = 0; gibmi < gcbmi; gibmi++) {
                gabmi[gibmi].pfnBenchmark(5);
            }
            gfAll = FALSE;

            DialogBox(ghinst, (LPSTR)IDD_RESULTS, hwnd, (DLGPROC)ResultsDlgProc);
            break;

        default:
            if (LOWORD(wParam) >= IDM_BENCHFIRST &&
                    LOWORD(wParam) < IDM_BENCHFIRST + gcbmi) {
                gibmi = LOWORD(wParam) - IDM_BENCHFIRST;
                gabmi[gibmi].pfnBenchmark(gabmi[gibmi].cIterations);
                break;
            }

            return DefFrameProc(hwnd, ghwndMDIClient, WM_COMMAND, wParam,
                    lParam);
        }
        break;

    case WM_CLOSE:
        DestroyWindow(hwnd);
        break;

    case WM_DESTROY:
        PostQuitMessage(0);
        break;

    default:
        /*
         * Use DefFrameProc() instead of DefWindowProc() since there are
         * things that have to be handled differently because of MDI.
         */
        return DefFrameProc(hwnd, ghwndMDIClient, msg, wParam, lParam);
    }

    return 0;
}
Пример #26
0
LRESULT WINEXPORT WREMainWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    HMENU       menu;
    LRESULT     ret;
    Bool        pass_to_def;
    WREResInfo  *res_info;
    WORD        wp;
    about_info  ai;

    if( WRECleanupStarted && message != WM_CLOSE ) {
        if( message == WM_DESTROY ) {
            PostQuitMessage( 0 );
        }
        return( DefFrameProc( hWnd, WREMDIWin, message, wParam, lParam ) );
    }

    pass_to_def = TRUE;
    ret = FALSE;
    res_info = WREGetCurrentRes();
    menu = WREGetMenuHandle();

    switch( message ) {
    case WM_DESTROYCLIPBOARD:
        WRForgetBitmapName();
        break;

    case WM_INITMENU:
        if( wParam == (WPARAM)GetMenu( hWnd ) ) {
            WRESetCopyMenuItem( hWnd );
            WRESetPasteMenuItem( hWnd );
        }
        break;

    case WM_MENUSELECT:
        WREHandleMenuSelect( wParam, lParam );
        break;

    case WM_MOVE:
        if( IsZoomed( hWnd ) ) {
            WRESetOption( WREOptScreenMax, TRUE );
        } else if( !IsIconic( hWnd ) ) {
            WREUpdateScreenPosOpt();
            WRESetOption( WREOptScreenMax, FALSE );
        }
        break;

    case WM_SIZE:
        if( wParam == SIZE_MAXIMIZED ) {
            WRESetOption( WREOptScreenMax, TRUE );
        } else if( wParam == SIZE_MINIMIZED ) {
            WREHideSessions( FALSE );
            WREIsMinimized = TRUE;
        } else {
            WREUpdateScreenPosOpt();
            WRESetOption( WREOptScreenMax, FALSE );
        }
        if( wParam != SIZE_MINIMIZED && WREIsMinimized ) {
            WREHideSessions( TRUE );
            BringWindowToTop( hWnd );
            WREIsMinimized = FALSE;
        }
        WREResizeWindows();
        pass_to_def = FALSE;
        break;

    case ACCEL_I_HAVE_CLOSED:
        WREEndEditAccelResource( (WAccelHandle)lParam );
        if( WRENoInterface ) {
            WRERemoveResource( res_info );
        }
        pass_to_def = FALSE;
        break;

    case ACCEL_PLEASE_SAVEME:
        WRESaveEditAccelResource( (WAccelHandle)lParam );
        pass_to_def = FALSE;
        break;

    case MENU_I_HAVE_CLOSED:
        WREEndEditMenuResource( (WMenuHandle)lParam );
        if( WRENoInterface ) {
            WRERemoveResource( res_info );
        }
        pass_to_def = FALSE;
        break;

    case MENU_PLEASE_SAVEME:
        WRESaveEditMenuResource( (WMenuHandle)lParam );
        pass_to_def = FALSE;
        break;

    case STRING_I_HAVE_CLOSED:
        WREEndEditStringResource( (WStringHandle)lParam );
        if( WRENoInterface ) {
            WRERemoveResource( res_info );
        }
        pass_to_def = FALSE;
        break;

    case STRING_PLEASE_SAVEME:
        WRESaveEditStringResource( (WStringHandle)lParam );
        pass_to_def = FALSE;
        break;

    case ACCEL_PLEASE_OPENME:
    case MENU_PLEASE_OPENME:
    case STRING_PLEASE_OPENME:
        ret = pleaseOpenFile( message );
        pass_to_def = FALSE;
        break;

    case WM_COMMAND:
        wp = LOWORD( wParam );
        switch( wp ) {
        case IDM_OPTIONS:
            pass_to_def = FALSE;
            break;

        case IDM_LOAD_SYMBOLS:
            WRELoadResourceSymbols( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_EDIT_SYMBOLS:
            WREEditResourceSymbols( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_SAVE_SYMBOLS:
            WREResourceSaveSymbols( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_NEW:
            WRECreateNewResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_OPEN:
            WREOpenResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_SAVE:
            WRESaveResource( res_info, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_SAVEAS:
            WRESaveResource( res_info, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_DELETE:
            WREDeleteCurrResource( FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_PASTE:
            WREPasteResource( hWnd );
            pass_to_def = FALSE;
            break;

        case IDM_CUT:
            WREClipCurrentResource( hWnd, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_COPY:
            WREClipCurrentResource( hWnd, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_NEW_CURSOR:
            WRENewImageResource( CursorService, (uint_16)RT_GROUP_CURSOR );
            break;

        case IDM_NEW_BITMAP:
            WRENewImageResource( BitmapService, (uint_16)RT_BITMAP );
            break;

        case IDM_NEW_ICON:
            WRENewImageResource( IconService, (uint_16)RT_GROUP_ICON );
            break;

        case IDM_NEW_DIALOG:
            WRENewDialogResource();
            break;

        case IDM_NEW_FONT:
        case IDM_NEW_RCDATA:
            pass_to_def = FALSE;
            break;

        case IDM_NEW_ACCELERATOR:
            WRENewAccelResource();
            pass_to_def = FALSE;
            break;

        case IDM_NEW_MENU:
            WRENewMenuResource();
            pass_to_def = FALSE;
            break;

        case IDM_NEW_STRING:
            WRENewStringResource();
            pass_to_def = FALSE;
            break;

        case IDM_RES_SAVEAS:
        case IDM_RES_SAVE_INTO:
            if( res_info != NULL ) {
                if( res_info->current_type == (uint_16)RT_STRING ) {
                    SaveMultObjects( wp == IDM_RES_SAVE_INTO );
                } else {
                    SaveObject( wp == IDM_RES_SAVE_INTO );
                }
            }
            pass_to_def = FALSE;
            break;

        case IDM_RES_EDIT:
            WREHandleResEdit();
            pass_to_def = FALSE;
            break;

        case IDM_RES_MEM_FLAGS:
            WREChangeMemFlags();
            pass_to_def = FALSE;
            break;

        case IDM_RES_RENAME:
            WRERenameResource();
            pass_to_def = FALSE;
            break;

        case IDM_MDI_CASCADE:
        case IDM_MDI_TILEV:
        case IDM_MDI_TILEH:
        case IDM_MDI_ARRANGE:
            WREHandleMDIArrangeEvents( wp );
            pass_to_def = FALSE;
            break;

        case IDM_EXIT:
            /* clean up before we exit */
            PostMessage( WREMainWin, WM_CLOSE, 0, 0 );
            break;

        case IDM_SHOW_RIBBON:
            WREShowRibbon( menu );
            pass_to_def = FALSE;
            break;

        case IDM_HELP:
            WREHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_SEARCH:
            WREHelpSearchRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_ON_HELP:
            WREHelpOnHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_ABOUT:
            ai.owner = hWnd;
            ai.inst = WREInst;
            ai.name = AllocRCString( WRE_ABOUT_NAME );
            ai.version = banner1p2( _RESEDIT_VERSION_ );
            ai.first_cr_year = AllocRCString( WRE_ABOUT_COPYRIGHT_YEAR );
            ai.title = AllocRCString( WRE_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.first_cr_year );
            FreeRCString( ai.title );
            pass_to_def = FALSE;
            break;
        }
        break;

    case WM_DESTROY:
        WWinHelp( WREMainWin, "resedt.hlp", HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;

    case WRE_FATAL_EXIT:
        WREFatalExit = TRUE;
        WREQueryKillApp( TRUE );
        PostMessage( WREMainWin, WM_CLOSE, 0, 0 );
        break;

    case WM_ENDSESSION:
        if( !wParam ) {
            WREFatalExit = FALSE;
        }
        break;

    case WM_QUERYENDSESSION:
        if( ret = WREQueryKillApp( FALSE ) ) {
            WREFatalExit = TRUE;
        }
        pass_to_def = FALSE;
        break;

    case WM_CLOSE:
        /* clean up before we exit */
        if( WRECleanupStarted ) {
            pass_to_def = FALSE;
            break;
        }
        WRECleanupStarted = TRUE;
        if( !WRECleanup( WREFatalExit ) ) {
            WRECleanupStarted = FALSE;
            pass_to_def = FALSE;
        }
    }

    if( pass_to_def ) {
        ret = DefFrameProc( hWnd, WREMDIWin, message, wParam, lParam );
    }
    return( ret );
}
Пример #27
0
/*
 * MainWindowProc - procedure for main (root) window
 */
WINEXPORT LRESULT CALLBACK MainWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    RECT        rect;
    vi_rc       rc;
    HANDLE      hfileinfo;
    int         cnt, i;
    char        *buff;

    switch( msg ) {
    case WM_CREATE:
        Root = hwnd;
        GetClientRect( hwnd, &rect );
        EditContainer = CreateContainerWindow( &rect );
        InitWindows();
        DragAcceptFiles( hwnd, TRUE );
        timerID = SetTimer( hwnd, TIMER_ID, 60L * 1000L, NULL );
        break;
    case WM_DROPFILES:
        hfileinfo = (HANDLE) wparam;
        cnt = DragQueryFile( hfileinfo, (UINT)-1, NULL, 0 );
        buff = alloca( FILENAME_MAX + 2 );   /* we add a " at the beginning and at the end so we can handle path- and filenames with spaces */
        if( buff != NULL ) {
            buff[0] = '"';      /* one " at the beginning of the filename */
            for( i = 0; i < cnt; i++ ) {
                if( DragQueryFile( hfileinfo, i, buff + 1, FILENAME_MAX ) == (UINT)-1 ) {
                    break;
                }
                strcat( buff, "\"" );
                rc = EditFile( buff, FALSE );
                if( rc > ERR_NO_ERR ) {
                    Error( GetErrorMsg( rc ) );
                }
            }
        }
        DragFinish( hfileinfo );
        break;
    case WM_TIMER:
        UpdateStatusWindow();
        break;
    case WM_KEYDOWN:
        if( WindowsKeyPush( wparam, HIWORD( lparam ) ) ) {
            return( 0 );
        }
        break;
    case WM_SIZE:
        DefFrameProc( hwnd, EditContainer, msg, wparam, lparam );
        RootState = wparam;
        if( wparam != SIZE_MINIMIZED ) {
            ResizeRoot();
            GetWindowRect( hwnd, &RootRect );
            if( wparam != SIZE_MAXIMIZED ) {
                RootState = 0;
            }
        }
        return( 0 );
    case WM_MOVE:
        DefFrameProc( hwnd, EditContainer, msg, wparam, lparam );
        if( RootState != SIZE_MINIMIZED ) {
            GetWindowRect( hwnd, &RootRect );
        }
        return( 0 );
    case WM_ACTIVATEAPP:
        if( BAD_ID( CurrentWindow ) ) {
            break;
        }
        SetFocus( Root );
#if 0
        if( !wparam ) {
            InactiveWindow( CurrentWindow );
        } else {
            SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L );
        }
#endif
        if( wparam ) {
            ResetEditWindowCursor( CurrentWindow );
        } else {
            GoodbyeCursor( CurrentWindow );
        }
        break;
    case WM_MOUSEACTIVATE:
        SetFocus( hwnd );
        return( MA_ACTIVATE );
    case WM_SETFOCUS:
        if( BAD_ID( CurrentWindow ) ) {
            break;
        }
        if( !IsIconic( CurrentWindow ) ) {
            SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L );
            DCUpdate();
            SetWindowCursor();
            SetWindowCursorForReal();
            return( 0 );
        }
        break;
    case WM_NCLBUTTONDBLCLK:
        break;
    case WM_COMMAND:
        if( LOWORD( wparam ) > 0xF000 ) {
            break;
        } else {
            rc = MenuCommand( LOWORD( wparam ) );
            if( rc != MENU_COMMAND_NOT_HANDLED ) {
                DCUpdateAll();
                if( rc > ERR_NO_ERR ) {
                    char        *msg;
                    msg = GetErrorMsg( rc );
                    Error( msg );
                }
            }
            SetWindowCursor();
        }
        return( 0 );
    case WM_INITMENU:
        if( (HMENU)wparam == GetMenu( hwnd ) ) {
            HandleInitMenu( (HMENU)wparam );
        } else {
            ResetMenuBits();
        }
        break;
    case WM_MENUSELECT:
        HandleMenuSelect( wparam, lparam );
        break;
    case WM_ENDSESSION:
        if( wparam ) {
            ExitEditor( 0 );
            // will not return
        }
        return( 0 );
    case WM_QUERYENDSESSION:
        return( ExitWithPrompt( FALSE, TRUE ) );
    case WM_CLOSE:
        ExitWithPrompt( TRUE, TRUE );
        return( 0 );
#ifdef __NT__        
    case WM_MOUSEWHEEL:
        {
            int     i, increment;
            ULONG   linesPerNotch;
            HWND    activeWnd;
            
            activeWnd = (HWND)SendMessage( EditContainer, WM_MDIGETACTIVE, 0, 0 );
            SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &linesPerNotch, 0 );
            
            increment = GET_WHEEL_DELTA_WPARAM( wparam ) / 120;
                // see WM_MOUSEWHEEL-documentation for information about the "120"

            if( increment > 0 ) {
                for( i = 0; i < increment * (int)linesPerNotch; i++ ) {
                    SendMessage( activeWnd, WM_VSCROLL, SB_LINEUP, 0 );
                }
            } else {
                for( i = 0; i < (-increment) * (int)linesPerNotch; i++ ) {
                    SendMessage( activeWnd, WM_VSCROLL, SB_LINEDOWN, 0 );
                }
            }
        }
        return( 0 );
#endif
    case WM_DESTROY:
        DestroyToolBar();
        DragAcceptFiles( hwnd, FALSE );
        EditContainer = 0;
        if( timerID ) {
            KillTimer( hwnd, TIMER_ID );
        }
        return( 0 );
    }
    return( DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ) );

} /* MainWindowProc */
Пример #28
0
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    CLIENTCREATESTRUCT ccs;
    HWND hwndChild = 0;
    
    if ( IsWindow(hwndMDIClient) )
        hwndChild = ChildGetActive();

    switch ( uMsg )
        {
        case WM_CREATE:
            /* following is regular MDI incantation */
            ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), WINDOW_MENU_POS);
            ccs.idFirstChild = IDM_WINDOW_CHILDREN;
            hwndMDIClient = CreateWindow(
                "mdiclient",
                NULL,
                WS_CHILD | WS_CLIPCHILDREN,
                0,
                0,
                0,
                0,
                hWnd,
                0,
                hinstThis,
                &ccs);
            if ( hwndMDIClient != 0 )
                {
                ShowWindow(hwndMDIClient, SW_SHOW);
                /* subclass the hwndMDIClient window so we can change the cursor
                    to a wait cursor when desired */
                pfnOldMDIClientWndProc =
                    (WNDPROC)SetWindowLong(hwndMDIClient, GWL_WNDPROC, (LONG)MDIClientWndProc);
                }
            return ( 0 );
        
        case WM_INITMENUPOPUP:
            /* some popup menu is about to be displayed */
            MenuStatus((int)LOWORD(lParam), (HMENU)wParam);
            return ( 0 );
        
        case WM_COMMAND:
            /* if WM_COMMAND is not from a control (then it's from a menu item) */
            if ( LOWORD(lParam) == 0 && MenuOnCommand(LOWORD(wParam)) )
                return ( 0 );
            break;

        case WM_QUERYENDSESSION:
            return ( ChildQueryCloseAll() );

        case WM_CLOSE:
            if ( !ChildQueryCloseAll() )
                return ( 0 );
            break;                
            
        case WM_DESTROY:
            WinHelp(hwndFrame, APPLICATION_HELPFILENAME, HELP_QUIT, 0);
            PostQuitMessage(0);
            return ( 0 );

        case WM_QUERYNEWPALETTE:
            /* set the system palette to the active child's palette */
            return ( OnQueryNewPalette(hwndChild) );

        case WM_MDIACTIVATE:
            /* set the system palette to the newly active child's palette */
            OnQueryNewPalette((HWND)wParam);
            return ( 0 );

        case WM_PALETTECHANGED:
            /* forwarded to children so they can each realize their background palettes */
            ForwardToChildren(hWnd, uMsg, wParam, lParam);
            return ( 0 );

        case WM_SYSCOLORCHANGE:
            Ctl3dColorChange();
            break;

        case WM_SYSCOMMAND:
            switch ( wParam & 0xfff0 )
                {
                case SC_MAXIMIZE:
                case SC_RESTORE:
                    /* since we effectively change our image origin when maximized or restored,
                        we have to _force_ the window repaint to include the entire window --
                        else win '95 (at least) optimizes away some of the regions */
                    DefFrameProc(hWnd, hwndMDIClient, uMsg, wParam, lParam);
                    if ( IsWindow(hwndChild) )
                        {
                        InvalidateRect(hwndChild, NULL, FALSE);
                        UpdateWindow(hwndChild);
                        }
                    return ( 0 );
                
                default:
                    break;                    
                }
            break;
            
        case WM_MOUSEMOVE:
            if ( nWaitCursor != 0 )
                SetCursor(hWaitCursor);
            else
                SetCursor(hArrowCursor);                
            break;
        
        default:
            break;
        }
    if ( !IsWindow(hwndMDIClient) )
        return ( DefFrameProc(hWnd, 0, uMsg, wParam, lParam) );
    return ( DefFrameProc(hWnd, hwndMDIClient, uMsg, wParam, lParam) );
}
Пример #29
0
static
LRESULT CALLBACK PxImageViewWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static int cxClient, cyClient;
	PAINTSTRUCT paintStruct;
	HDC hDC;
	PxImageViewObject* self = (PxImageViewObject*)GetWindowLongPtr(hwnd, GWLP_USERDATA);

	switch (msg)
	{
	case WM_PAINT:
		if (self->pyData && self->pyData != Py_None) {
			PxImageObject* pyImage = (PxImageObject*)self->pyData;
			hDC = BeginPaint(hwnd, &paintStruct);
			if (pyImage->pyImageFormat == PyObject_GetAttrString(g.pyImageFormatEnum, "bmp")) {
				HDC hdcMem = CreateCompatibleDC(hDC);
				HBITMAP hbmOld = SelectObject(hdcMem, pyImage->hWin);
				GetObject(pyImage->hWin, sizeof(BITMAP), &bitmap);
				if (self->bFill) {
					StretchBlt(hDC, 0, 0, cxClient, cyClient, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
				}
				else if (self->bStretch) {

					double dAspectRatio = (double)cxClient / cyClient;
					double dPictureAspectRatio = (double)bitmap.bmWidth / bitmap.bmHeight;

					if (dPictureAspectRatio > dAspectRatio)
					{
						int nNewHeight = (int)(cxClient / dPictureAspectRatio);
						int nCenteringFactor = (cyClient - nNewHeight) / 2;
						StretchBlt(hDC, 0, nCenteringFactor, cxClient, nNewHeight, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
					}
					else if (dPictureAspectRatio < dAspectRatio)
					{
						int nNewWidth = (int)(cyClient * dPictureAspectRatio);
						int nCenteringFactor = (cxClient - nNewWidth) / 2;
						StretchBlt(hDC, nCenteringFactor, 0, nNewWidth, cyClient, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
					}
					else
						StretchBlt(hDC, 0, 0, cxClient, cyClient, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
				}
				else
					BitBlt(hDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY);
				SelectObject(hdcMem, hbmOld);
			}
			else if (pyImage->pyImageFormat == PyObject_GetAttrString(g.pyImageFormatEnum, "ico")) {
				DrawIcon(hDC, 0, 0, pyImage->hWin);
			}
			EndPaint(hwnd, &paintStruct);
		}
		break;

	case WM_RBUTTONDOWN:
		PxImageView_OpenFileDialog(self);
		break;

	case WM_SIZE:
		cxClient = LOWORD(lParam);
		cyClient = HIWORD(lParam);
		return 0;

	case WM_QUERYENDSESSION:
	case WM_CLOSE:
		OutputDebugString(L"Window Closing!\n");
		if (TRUE)
			//DestroyWindow(hwnd);
			break;
		else
			return 0;

	case WM_DESTROY:
		OutputDebugString(L"Image Destroyed!\n");
		if (self != NULL)
			Py_DECREF(self);
		return 0;
	}
	return DefFrameProc(hwnd, g.hMDIClientArea, msg, wParam, lParam);
}
Пример #30
0
LRESULT CALLBACK _GMainMDIWindowProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
{
    CLIENTCREATESTRUCT ccs;
    RECT r;
    long retVal;
    short item;
    long ret;

    try {
        /*
         *	Try keyboard processing
         */

        if (-1 != (retVal = ProcessShellDDE(w,msg,wp,lp))) return retVal;
//		if (-1 != (retVal = XGAppCore::ProcKeyboardCommon(msg,wp,lp))) return retVal;

        /*
         *	Check for the activate message
         */

        if ((_GUpActive) && (_GUpActive == msg)) {
            ::SetWindowPos(w,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
            return 0;
        }

        /*
         *	Try the rest
         */

        switch (msg) {
        /*
         *	WM_CREATE construction
         */

        case WM_CREATE:
            ccs.hWindowMenu = NULL;
            ccs.idFirstChild = 10000;			// high number
            _GMDIWindow = ::CreateWindow("MDIClient","",
                                         WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | MDIS_ALLCHILDSTYLES,
                                         0,0,0,0,w,NULL,_GInstance,(LPSTR)&ccs);
            if (_GMDIWindow == NULL) return -1;	// failure
            ::ShowWindow(_GMDIWindow,SW_SHOW);
            return 0;

        /*
         *	WM_DESTROY destruction--kill app the hard way.
         */

        case WM_DESTROY:
            _GMainWindow = NULL;
            ::PostQuitMessage(0);
            return 0;

        /*
         *	WM_CLOSE: close main application event
         */

        case WM_CLOSE:
            XGDispatch::SendDispatch(KXGQuitApplication,0,NULL);
            return 0;

        /*	WM_QUERYENDSESSION:
         *
         *		Close session
         */

        case WM_QUERYENDSESSION:
            ret = XGDispatch::SendDispatch(KXGQuitApplication,0,NULL);
            if (ret == 0) return TRUE;		// success
            else return FALSE;				// failure


        /*	WM_MOVING, WM_MOVE, WM_SIZING, WM_SIZE
         *
         *		These events cause any inline editing to be closed.
         */

        case WM_MOVING:
        case WM_MOVE:
        case WM_SIZING:
            XGInline::Close();
            break;

        /*
         *	WM_SIZE: Resize event
         */

        case WM_SIZE:
            XGInline::Close();
            ::GetClientRect(w,&r);
            if (_GToolWindow) {
                ::MoveWindow(_GToolWindow,r.left,r.top,r.right-r.left,27,TRUE);
                r.top += 27;
            }
            ::MoveWindow(_GMDIWindow,r.left,r.top,
                         r.right-r.left,r.bottom-r.top,TRUE);
            return 0;

        /*
         *	WM_COMMAND: Process menu command
         */

        case WM_COMMAND:
            item = LOWORD(wp);
            if (-1 != XGDispatch::SendDispatch(KXGDoMenuCommand,item,NULL)) return 0;
            break;

        default:
            break;
        }

        return DefFrameProc(w,_GMDIWindow,msg,wp,lp);
    }

    catch (XGError &e) {
        e.DisplayError();
    }
    return 0;
}