Beispiel #1
0
void wxMenuBar::Attach(wxFrame *frame)
{
    wxMenuBarBase::Attach(frame);

#if defined(WINCE_WITH_COMMANDBAR)
    if (!m_hMenu)
        this->Create();
    if (!m_commandBar)
        m_commandBar = (WXHWND) CommandBar_Create(wxGetInstance(), (HWND) frame->GetHWND(), NewControlId());
    if (m_commandBar)
    {
        if (m_hMenu)
        {
            if (!CommandBar_InsertMenubarEx((HWND) m_commandBar, NULL, (LPTSTR) m_hMenu, 0))
            {
                wxLogLastError(wxT("CommandBar_InsertMenubarEx"));
            }
        }
    }
#endif

#if wxUSE_ACCEL
    RebuildAccelTable();
#endif // wxUSE_ACCEL
}
Beispiel #2
0
LRESULT CLogView::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
#if defined( OS_WINCE )

#if !defined (OS_PLATFORM_MOTCE)
	SHINITDLGINFO shidi;
	shidi.dwMask = SHIDIM_FLAGS; 
	shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;//SHIDIF_DONEBUTTON | SHIDIF_SIZEDLGFULLSCREEN |SHIDIF_EMPTYMENU; 
	shidi.hDlg = m_hWnd; 
	SHInitDialog(&shidi);

    SHMENUBARINFO mbi = { sizeof(mbi), 0 };
    mbi.hwndParent = m_hWnd;
    mbi.nToolBarId = IDR_LOGMENUBAR; // ID of toolbar resource
    mbi.hInstRes = _AtlBaseModule.GetResourceInstance();
    mbi.dwFlags    = SHCMBF_HMENU;
    SHCreateMenuBar(&mbi);

//    SendDlgItemMessage(IDC_LOGEDIT,WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT),0);
#else
	SetWindowLong(GWL_STYLE,(long)WS_BORDER);
	ShowWindow(SW_MAXIMIZE);

	m_hWndCommandBar = CommandBar_Create(_AtlBaseModule.GetResourceInstance(), m_hWnd, 1);
	CommandBar_AddAdornments(m_hWndCommandBar, 0, 0 );
	HMENU menu = LoadMenu(0, MAKEINTRESOURCE(IDR_LOGMENUBAR));
	CommandBar_InsertMenubarEx(m_hWndCommandBar, 0, (LPTSTR)menu, 0);
	CommandBar_DrawMenuBar(m_hWndCommandBar, 0);
    CommandBar_Show(m_hWndCommandBar, TRUE);
#endif

    loadLogText();

#elif defined(OS_WINDOWS)
	m_grip.InitGrip(m_hWnd);
	m_grip.ShowSizeGrip();
	CWindow edit = GetDlgItem(IDC_LOGEDIT);
	::SendMessage(edit.m_hWnd,EM_EXLIMITTEXT,0,2147483647);
	::SendMessage(edit.m_hWnd, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS);
	SetTimer(100,1000,NULL);

	RECT rc = { 0,0,500,400 };
	rc.left = getIniInt(_T("log_view_left"),0);
	rc.top = getIniInt(_T("log_view_top"),0);
	int width = getIniInt(_T("log_view_width"),500);
	rc.right = rc.left+width;
	int height = getIniInt(_T("log_view_height"),400);
	rc.bottom = rc.top+height;
	
	MoveWindow(&rc);
#endif //OS_

	bHandled = TRUE;
	return 1;  // Let the system set the focus
}
Beispiel #3
0
/*---------------------------------------------------------------------------*\
 |                                                                           |
\*---------------------------------------------------------------------------*/
BOOL OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
{
#define COUNT 10
    TCHAR * tch[] = { TEXT("Japan"), TEXT("Denmark"), TEXT("Albania"),
                            TEXT("Saudi Arabia"), TEXT("Kiribati"),
                            TEXT("Taiwan"), TEXT("Cameroon"), TEXT("Uganda"),
                            TEXT("France"), TEXT("Canada")};
    HWND hwndList;

    HDC        hdc;
    int        i;
    int        x, y, cx, cy;
    TEXTMETRIC tm;

    hdc = GetDC (NULL);
    GetTextMetrics (hdc, &tm);
    ReleaseDC (NULL, hdc);

    x  = 25;
    y  = 25;
    cx = tm.tmAveCharWidth * 25;
    cy = tm.tmHeight * 5;

	hwndList =
	CreateWindowEx(0,                /* Ext-style. */
					TEXT("listbox"), /* Class name.*/
					0L,              /* Title.     */
					WS_BORDER       |/* Style bits.*/
					WS_CHILD        |
					WS_VISIBLE      |
					WS_CLIPSIBLINGS |
					WS_VSCROLL      |
					LBS_NOTIFY      |
					LBS_SORT,
					x,               /* x.         */
					y,               /* y.         */
					cx,              /* cx.        */
					cy,              /* cy.        */
					hWnd,            /* Parent.    */
					(HMENU)ID_LIST,  /* Child Id.  */
					hInst,           /* Creator.   */
					NULL);           /* Params.    */

    for (i=0;i<COUNT;i++)
    {
        SendMessage (hwndList, LB_ADDSTRING, 0,
                     (LONG)(LPTSTR)tch[i]);
    }

	hwndCB = CommandBar_Create(hInst, hWnd, 1);			
	CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
	CommandBar_AddAdornments(hwndCB, 0, 0);

    return TRUE;
}
Beispiel #4
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	TCHAR szHello[MAX_LOADSTRING];

	switch (message) 
	{
        HANDLE_MSG(hWnd, WM_LBUTTONUP, OnLButtonUp);
        HANDLE_MSG(hWnd, WM_LBUTTONDOWN, OnLButtonDown);
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_HELP_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_FILE_EXIT:
				   DestroyWindow(hWnd);
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			hwndCB = CommandBar_Create(hInst, hWnd, 1);			
			CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
			CommandBar_AddAdornments(hwndCB, 0, 0);
			break;
		case WM_PAINT:
			RECT rt;
			hdc = BeginPaint(hWnd, &ps);
			GetClientRect(hWnd, &rt);
			LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
			DrawText(hdc, szHello, _tcslen(szHello), &rt, 
				DT_SINGLELINE | DT_VCENTER | DT_CENTER);
			EndPaint(hWnd, &ps);
			break;
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Beispiel #5
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

	
    switch (message) 
    {
        case WM_COMMAND:
            wmId    = LOWORD(wParam); 
            wmEvent = HIWORD(wParam); 
            // Parse the menu selections:
            switch (wmId)
            {
                case IDM_HELP_ABOUT:
                    DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About);
                    break;
                case IDM_FILE_EXIT:
                    DestroyWindow(hWnd);
                    break;
                default:
                    return DefWindowProc(hWnd, message, wParam, lParam);
            }
            break;
        case WM_CREATE:
            g_hWndCommandBar = CommandBar_Create(g_hInst, hWnd, 1);
            CommandBar_InsertMenubar(g_hWndCommandBar, g_hInst, IDR_MENU, 0);
            CommandBar_AddAdornments(g_hWndCommandBar, 0, 0);
            break;
        case WM_PAINT:
            hdc = BeginPaint(hWnd, &ps);
            
            // TODO: Add any drawing code here...
            
            EndPaint(hWnd, &ps);
            break;
        case WM_DESTROY:
            CommandBar_Destroy(g_hWndCommandBar);
            PostQuitMessage(0);
            break;


        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Beispiel #6
0
LRESULT CLogOptionsDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
#if defined( OS_WINCE )
if(winversion == 1)
{
//#if defined( OS_WINCE ) && !defined (OS_PLATFORM_MOTCE)
	SHINITDLGINFO shidi;
	shidi.dwMask = SHIDIM_FLAGS; 
	shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;//SHIDIF_DONEBUTTON | SHIDIF_SIZEDLGFULLSCREEN |SHIDIF_EMPTYMENU; 
	shidi.hDlg = m_hWnd; 
	SHInitDialog(&shidi);

    SHMENUBARINFO mbi = { sizeof(mbi), 0 };
    mbi.hwndParent = m_hWnd;
    mbi.nToolBarId = IDR_LOGOPTIONSMENUBAR; // ID of toolbar resource
    mbi.hInstRes = _AtlBaseModule.GetResourceInstance();
    mbi.dwFlags    = SHCMBF_HMENU;
    SHCreateMenuBar(&mbi);
}
else if(winversion == 2)
{
//#elif defined (OS_PLATFORM_MOTCE) 
	SetWindowLong(GWL_STYLE,(long)WS_BORDER);

	m_hWndCommandBar = CommandBar_Create(_AtlBaseModule.GetResourceInstance(), m_hWnd, 1);
	CommandBar_AddAdornments(m_hWndCommandBar, CMDBAR_OK, 0 );
    CommandBar_Show(m_hWndCommandBar, TRUE);
//#endif //OS_WINCE
}
#endif

    SendDlgItemMessage(IDC_CBXLEVELS,CB_ADDSTRING,0,  (LPARAM)_T("Trace"));
    SendDlgItemMessage(IDC_CBXLEVELS,CB_ADDSTRING,0,  (LPARAM)_T("Info"));
    SendDlgItemMessage(IDC_CBXLEVELS,CB_ADDSTRING,0,  (LPARAM)_T("Warning"));
    SendDlgItemMessage(IDC_CBXLEVELS,CB_ADDSTRING,0,  (LPARAM)_T("Error"));

    SendDlgItemMessage(IDC_CBXLEVELS,CB_SETCURSEL,LOGCONF().getMinSeverity(),0);

    CStringW strW(LOGCONF().getEnabledCategories().c_str());
    SetDlgItemText(IDC_MSGCLASSES, strW );
    strW = LOGCONF().getDisabledCategories().c_str();
    SetDlgItemText(IDC_MSGEXCLUDE, strW );

	bHandled = TRUE;
	return 1;  // Let the system set the focus
}
Beispiel #7
0
/*---------------------------------------------------------------------------*\
 |                                                                           |
\*---------------------------------------------------------------------------*/
BOOL OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
{
    HDC hdc;
    TEXTMETRIC tm;

	// Setup the HPC command bar.
	hwndCB = CommandBar_Create(hInst, hWnd, 1);			
	CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
	CommandBar_AddAdornments(hwndCB, 0, 0);

    hdc = GetDC (hWnd);
    GetTextMetrics (hdc, &tm);
    xMargin = tm.tmAveCharWidth;
    yMargin = tm.tmHeight / 2 + CommandBar_Height(hwndCB);
    ReleaseDC (hWnd, hdc);

    return TRUE;
}
Beispiel #8
0
bool wxToolMenuBar::MSWCreateToolbar(const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), wxMenuBar* menuBar)
{
    SetMenuBar(menuBar);
    if (m_menuBar)
        m_menuBar->SetToolBar(this);

#if defined(WINCE_WITHOUT_COMMANDBAR)
    // Create the menubar.
    SHMENUBARINFO mbi;

    memset (&mbi, 0, sizeof (SHMENUBARINFO));
    mbi.cbSize     = sizeof (SHMENUBARINFO);
    mbi.hwndParent = (HWND) GetParent()->GetHWND();
#ifdef __SMARTPHONE__
    mbi.nToolBarId = 5002;
#else
    mbi.nToolBarId = 5000;
#endif
    mbi.nBmpId     = 0;
    mbi.cBmpImages = 0;
    mbi.dwFlags = 0 ; // SHCMBF_EMPTYBAR;
    mbi.hInstRes = wxGetInstance();

    if (!SHCreateMenuBar(&mbi))
    {
        wxFAIL_MSG( _T("SHCreateMenuBar failed") );
        return false;
    }

    SetHWND((WXHWND) mbi.hwndMB);
#else
    HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND) GetParent()->GetHWND(), GetId());
    SetHWND((WXHWND) hWnd);
#endif

    // install wxWidgets window proc for this window
    SubclassWin(m_hWnd);

    if (menuBar)
        menuBar->Create();

    return true;
}
bool wxToolMenuBar::MSWCreateToolbar(const wxPoint& WXUNUSED(pos),
                                     const wxSize& WXUNUSED(size),
                                     wxMenuBar *menuBar)
{
    SetMenuBar(menuBar);
    if (m_menuBar)
        m_menuBar->SetToolBar(this);

    HWND hwndParent = GetHwndOf(GetParent());
    wxCHECK_MSG( hwndParent, false, wxT("should have valid parent HWND") );

#if defined(WINCE_WITHOUT_COMMANDBAR)
    // create the menubar.
    WinStruct<SHMENUBARINFO> mbi;

    mbi.hwndParent = hwndParent;
    mbi.nToolBarId = wxIDM_SHMENU;
    mbi.hInstRes = wxGetInstance();

    if ( !SHCreateMenuBar(&mbi) )
    {
        wxFAIL_MSG( wxT("SHCreateMenuBar failed") );
        return false;
    }

    SetHWND((WXHWND) mbi.hwndMB);
#else
    HWND hWnd = CommandBar_Create(wxGetInstance(), hwndParent, GetId());
    SetHWND((WXHWND) hWnd);
#endif

    // install wxWidgets window proc for this window
    SubclassWin(m_hWnd);

    if (menuBar)
        menuBar->Create();

    return true;
}
Beispiel #10
0
static void OnCreate (HWND hWnd)
{
    enum {
        X = 10,
        Y = 40,
        W = 220,
        H = 30,
    };

    DWORD dwStyle;

    hMainWnd = hWnd;

    hwndCB = CommandBar_Create (hInst, hWnd, 1);
    CommandBar_InsertMenubar (hwndCB, hInst, IDM_MENU, 0);
    CommandBar_AddAdornments (hwndCB, 0, 0);

    // Create global status text
    dwStyle = WS_CHILD | WS_VISIBLE | WS_DISABLED | ES_LEFT;
    hwndGlobalStatus = CreateWindow (
                           TEXT ("EDIT"),  // Class name
                           NULL,           // Window text
                           dwStyle,        // Window style
                           X,		// x-coordinate of the upper-left corner
                           Y+0,            // y-coordinate of the upper-left corner
                           W,		// Width of the window for the edit
                           // control
                           H-5,		// Height of the window for the edit
                           // control
                           hWnd,           // Window handle to the parent window
                           (HMENU) ID_GLOBAL_STATUS, // Control identifier
                           hInst,           // Instance handle
                           NULL);          // Specify NULL for this parameter when
    // you create a control
    SetLocalURI (g_local_uri.ptr, g_local_uri.slen, false);


    // Create URI edit
    dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER;
    hwndURI = CreateWindow (
                  TEXT ("EDIT"),  // Class name
                  NULL,		// Window text
                  dwStyle,        // Window style
                  X,  // x-coordinate of the upper-left corner
                  Y+H,  // y-coordinate of the upper-left corner
                  W,  // Width of the window for the edit
                  // control
                  H-5,  // Height of the window for the edit
                  // control
                  hWnd,           // Window handle to the parent window
                  (HMENU) ID_URI, // Control identifier
                  hInst,           // Instance handle
                  NULL);          // Specify NULL for this parameter when
    // you create a control

    // Create action Button
    hwndActionButton = CreateWindow (L"button", L"Action",
                                     WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                     X, Y+2*H,
                                     60, H-5, hWnd,
                                     (HMENU) ID_BTN_ACTION,
                                     hInst, NULL);

    // Create exit button
    hwndExitButton = CreateWindow (L"button", L"E&xit",
                                   WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                   X+70, Y+2*H,
                                   60, H-5, hWnd,
                                   (HMENU) ID_EXIT,
                                   hInst, NULL);


    // Create call status edit
    dwStyle = WS_CHILD | WS_VISIBLE | WS_DISABLED;
    hwndCallStatus = CreateWindow (
                         TEXT ("EDIT"),  // Class name
                         NULL,		// Window text
                         dwStyle,        // Window style
                         X,  // x-coordinate of the upper-left corner
                         Y+3*H,  // y-coordinate of the upper-left corner
                         W,  // Width of the window for the edit
                         // control
                         H-5,  // Height of the window for the edit
                         // control
                         hWnd,           // Window handle to the parent window
                         (HMENU) ID_CALL_STATUS, // Control identifier
                         hInst,           // Instance handle
                         NULL);          // Specify NULL for this parameter when
    // you create a control
    SetCallStatus ("Ready", 5);
    SetAction (ID_MENU_CALL);
    SetURI (SIP_DST_URI, -1);
    SetFocus (hWnd);

}
NOEXPORT LRESULT CALLBACK window_proc(HWND main_window_handle,
        UINT message, WPARAM wParam, LPARAM lParam) {
    NOTIFYICONDATA nid;
    POINT pt;
    RECT rect;
    SERVICE_OPTIONS *section;
    unsigned int section_number;

#if 0
    if(message!=WM_CTLCOLORSTATIC && message!=WM_TIMER)
        s_log(LOG_DEBUG, "Window message: %d", message);
#endif
    switch(message) {
    case WM_CREATE:
#ifdef _WIN32_WCE
        /* create command bar */
        command_bar_handle=CommandBar_Create(ghInst, main_window_handle, 1);
        if(!command_bar_handle)
            error_box("CommandBar_Create");
        if(!CommandBar_InsertMenubar(command_bar_handle, ghInst, IDM_MAINMENU, 0))
            error_box("CommandBar_InsertMenubar");
        if(!CommandBar_AddAdornments(command_bar_handle, 0, 0))
            error_box("CommandBar_AddAdornments");
#endif

        /* create child edit window */
        edit_handle=CreateWindow(TEXT("EDIT"), NULL,
            WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_READONLY,
            0, 0, 0, 0, main_window_handle, (HMENU)IDE_EDIT, ghInst, NULL);
#ifndef _WIN32_WCE
        SendMessage(edit_handle, WM_SETFONT,
            (WPARAM)CreateFont(-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
                DEFAULT_CHARSET, OUT_RASTER_PRECIS, CLIP_DEFAULT_PRECIS,
                PROOF_QUALITY, DEFAULT_PITCH, TEXT("Courier")),
            MAKELPARAM(FALSE, 0)); /* no need to redraw right, now */
#endif
        /* NOTE: there's no return statement here -> proceeding with resize */

    case WM_SIZE:
        GetClientRect(main_window_handle, &rect);
#ifdef _WIN32_WCE
        MoveWindow(edit_handle, 0, CommandBar_Height(command_bar_handle),
            rect.right, rect.bottom-CommandBar_Height(command_bar_handle), TRUE);
#else
        MoveWindow(edit_handle, 0, 0, rect.right, rect.bottom, TRUE);
#endif
        UpdateWindow(edit_handle);
        /* CommandBar_Show(command_bar_handle, TRUE); */
        return TRUE;

    case WM_SETFOCUS:
        SetFocus(edit_handle);
        return TRUE;

    case WM_TIMER:
        if(visible)
            update_logs();
        return TRUE;

    case WM_CLOSE:
        ShowWindow(main_window_handle, SW_HIDE);
        return TRUE;

    case WM_SHOWWINDOW:
        visible=wParam; /* setup global variable */
        if(tray_menu_handle)
            CheckMenuItem(tray_menu_handle, IDM_SHOW_LOG,
                visible ? MF_CHECKED : MF_UNCHECKED);
        if(visible)
            update_logs();
        return TRUE;

    case WM_DESTROY:
#ifdef _WIN32_WCE
        CommandBar_Destroy(command_bar_handle);
#else
        if(main_menu_handle)
            DestroyMenu(main_menu_handle);
#endif
        if(tray_menu_handle)
            DestroyMenu(tray_menu_handle);
        ZeroMemory(&nid, sizeof nid);
        nid.cbSize=sizeof nid;
        nid.hWnd=main_window_handle;
        nid.uID=1;
        nid.uFlags=NIF_TIP; /* not really sure what to put here, but it works */
        Shell_NotifyIcon(NIM_DELETE, &nid); /* this removes the icon */
        PostQuitMessage(0);
        KillTimer(main_window_handle, 0x29a);
        return TRUE;

    case WM_COMMAND:
        if(wParam>=IDM_PEER_MENU && wParam<IDM_PEER_MENU+number_of_sections) {
            for(section=service_options.next, section_number=0;
                    section && wParam!=IDM_PEER_MENU+section_number;
                    section=section->next, ++section_number)
                ;
            if(!section)
                return TRUE;
            if(save_text_file(section->file, section->chain))
                return TRUE;
#ifndef _WIN32_WCE
            if(main_menu_handle)
                CheckMenuItem(main_menu_handle, wParam, MF_CHECKED);
#endif
            if(tray_menu_handle)
                CheckMenuItem(tray_menu_handle, wParam, MF_CHECKED);
            message_box(section->help, MB_ICONINFORMATION);
            return TRUE;
        }
        switch(wParam) {
        case IDM_ABOUT:
            DialogBox(ghInst, TEXT("AboutBox"), main_window_handle,
                (DLGPROC)about_proc);
            break;
        case IDM_SHOW_LOG:
            if(visible) {
                ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            } else {
                ShowWindow(main_window_handle, SW_SHOWNORMAL); /* show window */
                SetForegroundWindow(main_window_handle); /* bring on top */
            }
            break;
        case IDM_CLOSE:
            ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            break;
        case IDM_EXIT:
            if(!error_mode) /* signal_pipe is active */
                signal_post(SIGNAL_TERMINATE);
            DestroyWindow(main_window_handle);
            break;
        case IDM_SAVE_LOG:
            if(!cmdline.service) /* security */
                save_log();
            break;
        case IDM_EDIT_CONFIG:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                edit_config(main_window_handle);
#endif
            break;
        case IDM_RELOAD_CONFIG:
            if(error_mode) /* unlock daemon_thread */
                SetEvent(config_ready);
            else /* signal_pipe is active */
                signal_post(SIGNAL_RELOAD_CONFIG);
            break;
        case IDM_REOPEN_LOG:
            signal_post(SIGNAL_REOPEN_LOG);
            break;
        case IDM_MANPAGE:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                ShellExecute(main_window_handle, TEXT("open"),
                    TEXT("stunnel.html"), NULL, NULL, SW_SHOWNORMAL);
#endif
            break;
        case IDM_HOMEPAGE:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                ShellExecute(main_window_handle, TEXT("open"),
                    TEXT("http://www.stunnel.org/"), NULL, NULL, SW_SHOWNORMAL);
#endif
            break;
        }
        return TRUE;

    case WM_SYSTRAY: /* a taskbar event */
        switch(lParam) {
#ifdef _WIN32_WCE
        case WM_LBUTTONDOWN: /* no right mouse button on Windows CE */
            GetWindowRect(GetDesktopWindow(), &rect); /* no cursor position */
            pt.x=rect.right;
            pt.y=rect.bottom-25;
#else
        case WM_RBUTTONDOWN:
            GetCursorPos(&pt);
#endif
            SetForegroundWindow(main_window_handle);
            TrackPopupMenuEx(GetSubMenu(tray_menu_handle, 0), TPM_BOTTOMALIGN,
                pt.x, pt.y, main_window_handle, NULL);
            PostMessage(main_window_handle, WM_NULL, 0, 0);
            break;
#ifndef _WIN32_WCE
        case WM_LBUTTONDBLCLK: /* switch log window visibility */
            if(visible) {
                ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            } else {
                ShowWindow(main_window_handle, SW_SHOWNORMAL); /* show window */
                SetForegroundWindow(main_window_handle); /* bring on top */
            }
            break;
#endif
        }
        return TRUE;

    case WM_VALID_CONFIG:
        valid_config();
        return TRUE;

    case WM_INVALID_CONFIG:
        invalid_config();
        return TRUE;

    case WM_LOG:
        win_log((LPSTR)wParam);
        return TRUE;

    case WM_NEW_CHAIN:
#ifndef _WIN32_WCE
        if(main_menu_handle)
            EnableMenuItem(main_menu_handle, IDM_PEER_MENU+wParam, MF_ENABLED);
#endif
        if(tray_menu_handle)
            EnableMenuItem(tray_menu_handle, IDM_PEER_MENU+wParam, MF_ENABLED);
        return TRUE;

    case WM_CLIENTS:
        update_tray_icon((int)wParam);
        return TRUE;
    }

    return DefWindowProc(main_window_handle, message, wParam, lParam);
}
Beispiel #12
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	/*if (message>1000)
	{
	 	FILE * pFileTXT;
	
		SYSTEMTIME st;
		GetLocalTime(&st);
		pFileTXT = fopen (fname,"a");
		fprintf(pFileTXT, "-------> Date: [%02d, %02d, %d]  Time: [%02d:%02d:%02d] " ,st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond);
		fprintf (pFileTXT, " wnd(%d) msg(%d) wParam(%d-%d) lParam(%d-%d) \n", hWnd,message,LOWORD(wParam), HIWORD(wParam),LOWORD(lParam), HIWORD(lParam));

		fclose (pFileTXT);
	}*/
	switch (message) 
	{
	
	case WM_COMMAND:
		wmId    = LOWORD(wParam); 
		wmEvent = HIWORD(wParam); 
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_HELP_ABOUT:

			DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About);
			break;
		case IDM_FILE_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_CREATE:
		g_hWndCommandBar = CommandBar_Create(g_hInst, hWnd, 1);
		CommandBar_InsertMenubar(g_hWndCommandBar, g_hInst, IDR_MENU, 0);
		CommandBar_AddAdornments(g_hWndCommandBar, 0, 0);

		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);

		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		CommandBar_Destroy(g_hWndCommandBar);
		if (hWnd_navitel) 
			DestroyWindow(hWnd_navitel);
		//if (pi_navitel.hProcess)
		//	TerminateProcess(pi_navitel.hProcess,NO_ERROR);
		PostQuitMessage(0);
		break;

	default:

		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Beispiel #13
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_HELP_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_FILE_EXIT:
				   DestroyWindow(hWnd);
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			hwndCB = CommandBar_Create(hInst, hWnd, 1);			
			CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
			CommandBar_AddAdornments(hwndCB, 0, 0);
			break;
		case WM_PAINT:
		{
			hdc = BeginPaint(hWnd, &ps);

			HPEN hpen1, hpen2;
			HBRUSH hbr1, hbr2;

			hpen1 = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
			hpen2 = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
			hbr1 = CreateSolidBrush(RGB(0, 255, 0));
			hbr2 = CreateSolidBrush(RGB(0, 255, 255));

			SelectObject(hdc, hpen1);
			POINT pt[2];
			pt[0].x = 10;
			pt[0].y = 50;
			pt[1].x = 110;
			pt[1].y = 50;
			Polyline(hdc, pt, 2);

			SelectObject(hdc, hbr1);
			Rectangle(hdc, 60, 60, 180, 180);

			SelectObject(hdc, hpen2);
			pt[0].x = 20;
			pt[0].y = 40;
			pt[1].x = 20;
			pt[1].y = 220;
			Polyline(hdc, pt, 2);

			SelectObject(hdc, hbr2);
			Rectangle(hdc, 200, 200, 450, 350);

			// Clean Up all objects created.
			SelectObject(hdc, GetStockObject(BLACK_PEN));
			SelectObject(hdc, GetStockObject(WHITE_BRUSH));
			DeleteObject(hpen1);
			DeleteObject(hpen2);
			DeleteObject(hbr1);
			DeleteObject(hbr2);
			EndPaint(hWnd, &ps);
		}
			break;
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Beispiel #14
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_HELP_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_FILE_EXIT:
				   DestroyWindow(hWnd);
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			hwndCB = CommandBar_Create(hInst, hWnd, 1);			
			CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
			CommandBar_AddAdornments(hwndCB, 0, 0);
			break;
		case WM_PAINT:
		{
			HDC hdc;
			PAINTSTRUCT ps;
			hdc = BeginPaint(hWnd, &ps);
			TEXTMETRIC tm;
			int x = 10;
			int y = CommandBar_Height(hwndCB);
			int cyLineHeight;

			GetTextMetrics(hdc, &tm);
			cyLineHeight = tm.tmHeight + tm.tmExternalLeading;

			SetTextColor(hdc, RGB(255, 0, 0));
			SetBkColor(hdc, RGB(0, 255, 255));
			ExtTextOut (hdc, x, y, 0, NULL, TEXT("First Line"), 10, NULL);
			y += cyLineHeight;

			SetTextColor(hdc, RGB(0, 255, 0));
			SetBkColor(hdc, RGB(255, 0, 255));
			ExtTextOut (hdc, x, y, 0, NULL, TEXT("Second Line"), 11, NULL);
			y += cyLineHeight;

			SetTextColor(hdc, RGB(0, 0, 255));
			SetBkColor(hdc, RGB(255, 255, 0));
			ExtTextOut (hdc, x, y, 0, NULL, TEXT("Third Line"), 10, NULL);
			y += cyLineHeight;

			EndPaint(hWnd, &ps);
		}
			break;
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Beispiel #15
0
static LRESULT CALLBACK wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
    NOTIFYICONDATA nid;
    POINT pt;
    RECT rect;
    LPTSTR txt;

#if 0
    if(message!=WM_CTLCOLORSTATIC && message!=WM_TIMER)
        s_log(LOG_DEBUG, "Window message: %d", message);
#endif
    switch (message) {
    case WM_CREATE:
        if (options.option.taskbar) /* taskbar update enabled? */
            SetTimer(hwnd, 0x29a, 1000, NULL); /* 1-second timer */

#ifdef _WIN32_WCE
        /* create command bar */
        hwndCB=CommandBar_Create(ghInst, hwnd, 1);
        if(!hwndCB)
            error_box(TEXT("CommandBar_Create"));
        if(!CommandBar_InsertMenubar(hwndCB, ghInst, IDM_MAINMENU, 0))
            error_box(TEXT("CommandBar_InsertMenubar"));
        if(!CommandBar_AddAdornments(hwndCB, 0, 0))
            error_box(TEXT("CommandBar_AddAdornments"));
#endif

        /* create child edit window */
        EditControl=CreateWindow(TEXT("EDIT"), NULL,
            WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_READONLY,
            0, 0, 0, 0, hwnd, (HMENU)IDE_EDIT, ghInst, NULL);
#ifndef _WIN32_WCE
        SendMessage(EditControl, WM_SETFONT,
            (WPARAM)GetStockObject(OEM_FIXED_FONT),
        MAKELPARAM(FALSE, 0)); /* no need to redraw right, now */
#endif

        /* NOTE: there's no return statement here -> proceeding with resize */

    case WM_SIZE:
        GetClientRect(hwnd, &rect);
#ifdef _WIN32_WCE
        MoveWindow(EditControl, 0, CommandBar_Height(hwndCB),
            rect.right, rect.bottom-CommandBar_Height(hwndCB), TRUE);
#else
        MoveWindow(EditControl, 0, 0, rect.right, rect.bottom, TRUE);
#endif
        UpdateWindow(EditControl);
        /* CommandBar_Show(hwndCB, TRUE); */
        return TRUE;

    case WM_SETFOCUS:
        txt=log_txt();
        SetWindowText(EditControl, txt);
        free(txt);
        SetFocus(EditControl);
        return TRUE;

    case WM_TIMER:
        update_taskbar();
        return TRUE;

    case WM_CLOSE:
        set_visible(0);
        return TRUE;

    case WM_DESTROY:
#ifdef _WIN32_WCE
        CommandBar_Destroy(hwndCB);
#else
        if(hmainmenu)
            DestroyMenu(hmainmenu);
#endif
        if(htraymenu)
            DestroyMenu(htraymenu);
        ZeroMemory(&nid, sizeof(nid));
        nid.cbSize=sizeof(NOTIFYICONDATA);
        nid.hWnd=hwnd;
        nid.uID=1;
        nid.uFlags=NIF_TIP; /* not really sure what to put here, but it works */
        Shell_NotifyIcon(NIM_DELETE, &nid); /* this removes the icon */
        PostQuitMessage(0);
        KillTimer(hwnd, 0x29a);
        return TRUE;

    case WM_COMMAND:
        switch(wParam) {
        case IDM_ABOUT:
            DialogBox(ghInst, TEXT("AboutBox"), hwnd, (DLGPROC)about_proc);
            break;
        case IDM_LOG:
            set_visible(!visible);
            break;
        case IDM_CLOSE:
            set_visible(0);
            break;
        case IDM_EXIT:
            DestroyWindow(hwnd);
            break;
        case IDM_SAVEAS:
            save_file(hwnd);
            break;
        case IDM_SETUP:
            MessageBox(hwnd, TEXT("Function not implemented"),
                win32_name, MB_ICONERROR);
            break;
        }
        return TRUE;

    case UWM_SYSTRAY: /* a taskbar event */
        switch (lParam) {
#ifdef _WIN32_WCE
        case WM_LBUTTONDOWN: /* no right mouse button on Windows CE */
            GetWindowRect(GetDesktopWindow(), &rect); /* no cursor position */
            pt.x=rect.right;
            pt.y=rect.bottom-25;
#else
        case WM_RBUTTONDOWN:
            GetCursorPos(&pt);
#endif
            SetForegroundWindow(hwnd);
            TrackPopupMenuEx(hpopup, TPM_BOTTOMALIGN, pt.x, pt.y, hwnd, NULL);
            PostMessage(hwnd, WM_NULL, 0, 0);
            break;
#ifndef _WIN32_WCE
        case WM_LBUTTONDBLCLK: /* switch log window visibility */
            set_visible(!visible);
            break;
#endif
        }
        return TRUE;
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}
/* Set a "Menu Bar" on the given frame.
 * PocketPC places menubars at the bottom, which are non-dynamic 
 * so we have a place holder menu item, which takes one to the menu-bar 
 */
WCECOMPAT_API HWND __cdecl
wceSetMenuBar(HWND frame, HWND cmdBarWnd, HMENU menu)
{
#ifdef POCKETPC_MENUS 
    static HMENU javaMenu = NULL;
    HMENU hMenuBar, subMenu;
    SHMENUBARINFO mb;

    /* What we have to do here is pretty bad */
    if (!theInstance) {
	return NULL;
    } 
    if (!frame) {
	return NULL;
    }
    if (1)  {
	/* Only way of creating a menubar is by loading it from a resouce */
	/* This load is a sanity check */
	javaMenu = LoadMenu(theInstance, MAKEINTRESOURCE(IDR_MENUBAR1));
        if (!javaMenu) {
	    return NULL;
	}

	memset(&mb, 0, sizeof(SHMENUBARINFO));
	mb.cbSize = sizeof(SHMENUBARINFO);
	mb.hwndParent = frame;
	mb.dwFlags = 0;
	mb.nToolBarId = IDR_MENUBAR1;
	mb.nBmpId = 0;
	mb.hInstRes =  theInstance;
	mb.cBmpImages =  0;
	/* If this fails,  we're toast */
	if (!SHCreateMenuBar(&mb)) {
	    return NULL;
	}
	cmdBarWnd = mb.hwndMB;
	if (!cmdBarWnd) {
	    return NULL;
	}
    }

    theCmdBarWnd = cmdBarWnd;
    javaMenu = SHGetMenu(cmdBarWnd);
    subMenu = GetSubMenu(javaMenu, 0);
    if (!subMenu) {
	return NULL;
    }
    
    /* Now, we simply cannot set the commandbar menu */
    /* but we can set its submenu, by sending it the */
    /* SHCMBM_SETSUBMENU message */

    SHSetSubMenu(cmdBarWnd, JAVA_MENU_ID, menu); /* this is a marco, defined above */
#else  /* ! POCKETPC_MENUS */
    #define ID_CMDBAR 199
    cmdBarWnd = CommandBar_Create(GetModuleHandle(NULL), frame, ID_CMDBAR);
    if (!CommandBar_InsertMenubarEx(cmdBarWnd,
				    NULL,// No instance implies handle
				    (LPTSTR) menu,
				    0)) {
	// Failure
	return (NULL);
    }
#endif POCKETPC_MENUS
#ifdef OBSOLOLETE
    theFrameWnd = frame;
#endif
    return cmdBarWnd;
    
}
Beispiel #17
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;

	switch (message) 
	{
        HANDLE_MSG(hWnd, WM_PAINT, OnPaint);

		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_OPEN:
				{
					TCHAR szPathName[_MAX_PATH];    // Maximum file name size is 260 characters.
					OPENFILENAME ofn;

					BOOL bReturn;
					DWORD dw;
					int cbSize = sizeof(OPENFILENAME);

					szPathName[0] = 0;

					memset(&ofn, 0, cbSize);
					ofn.lStructSize = cbSize;
					ofn.hwndOwner = hWnd;
					ofn.lpstrFilter = TEXT("Text files\0*.txt\0All files\0*.*\0");
					ofn.nFilterIndex = 1;
					ofn.lpstrFile = szPathName;
					ofn.nMaxFile = _MAX_PATH;
					ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
					ofn.lpstrDefExt = TEXT("txt");
					bReturn = GetOpenFileName(&ofn);
					if(bReturn)
					{
						MessageBox(hWnd,szPathName,_T("File Selected"),MB_OK);
						HANDLE hFile = CreateFile(szPathName, 
										   GENERIC_READ,
										   FILE_SHARE_READ,
										   NULL,
										   OPEN_EXISTING,
										   FILE_ATTRIBUTE_NORMAL,
										   NULL);
						if (hFile == (HANDLE)0xffffffff)
						{
							MessageBox(hWnd, TEXT("Call to CreateFile failed"), achAppName, MB_OK);
							return 0L;
						}

						// Free memory if we've allocated any before.
						if (pData)
						{
    
							VirtualFree(pData, 0, MEM_RELEASE);
							pData = NULL;
						}

						// Determine file size first.
						DWORD dwFileSize = GetFileSize(hFile, NULL);
						pData = (TCHAR *)VirtualAlloc(NULL, dwFileSize, MEM_COMMIT, PAGE_READWRITE);

						DWORD dwRead;
						ReadFile(hFile, pData, dwFileSize, &dwRead, NULL);
						CloseHandle(hFile);

						InvalidateRect(hWnd, NULL, TRUE);
						return 0L;
					}
					else
					{
						dw = CommDlgExtendedError();
						if(dw==0)
							MessageBox(hWnd,_T("User clicked cancel"),_T("Open"),MB_OK);
						else
							MessageBox(hWnd,_T("Error"),_T("Open"),MB_OK);
					}
				}
				    break;
				case IDM_HELP_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_FILE_EXIT:
				   DestroyWindow(hWnd);
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			hwndCB = CommandBar_Create(hInst, hWnd, 1);			
			CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
			CommandBar_AddAdornments(hwndCB, 0, 0);
			break;
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Beispiel #18
0
NOEXPORT LRESULT CALLBACK window_proc(HWND main_window_handle,
        UINT message, WPARAM wParam, LPARAM lParam) {
    POINT pt;
    RECT rect;
    PAINTSTRUCT ps;
    SERVICE_OPTIONS *section;
    unsigned section_number;
    LPTSTR txt;

#if 0
    switch(message) {
    case WM_CTLCOLORSTATIC:
    case WM_TIMER:
    case WM_LOG:
        break;
    default:
        s_log(LOG_DEBUG, "Window message: 0x%x(0x%hx,0x%lx)",
            message, wParam, lParam);
    }
#endif
    switch(message) {
    case WM_CREATE:
#ifdef _WIN32_WCE
        /* create command bar */
        command_bar_handle=CommandBar_Create(ghInst, main_window_handle, 1);
        if(!command_bar_handle)
            error_box(TEXT("CommandBar_Create"));
        if(!CommandBar_InsertMenubar(command_bar_handle, ghInst, IDM_MAINMENU, 0))
            error_box(TEXT("CommandBar_InsertMenubar"));
        if(!CommandBar_AddAdornments(command_bar_handle, 0, 0))
            error_box(TEXT("CommandBar_AddAdornments"));
#endif

        /* create child edit window */
        edit_handle=CreateWindowEx(WS_EX_STATICEDGE, TEXT("EDIT"), NULL,
            WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_READONLY,
            0, 0, 0, 0, main_window_handle, (HMENU)IDE_EDIT, ghInst, NULL);
#ifndef _WIN32_WCE
        SendMessage(edit_handle, WM_SETFONT,
            (WPARAM)CreateFont(-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
                DEFAULT_CHARSET, OUT_RASTER_PRECIS, CLIP_DEFAULT_PRECIS,
                PROOF_QUALITY, DEFAULT_PITCH, TEXT("Courier")),
            MAKELPARAM(FALSE, 0)); /* no need to redraw right now */
#endif
        /* NOTE: there's no return statement here -> proceeding with resize */

    case WM_SIZE:
        GetClientRect(main_window_handle, &rect);
#ifdef _WIN32_WCE
        MoveWindow(edit_handle, 0, CommandBar_Height(command_bar_handle),
            rect.right, rect.bottom-CommandBar_Height(command_bar_handle),
            TRUE);
        SendMessage(command_bar_handle, TB_AUTOSIZE, 0L, 0L);
        CommandBar_AlignAdornments(command_bar_handle);
#else
        MoveWindow(edit_handle, 0, 0, rect.right, rect.bottom, TRUE);
#endif
        UpdateWindow(edit_handle);
        /* CommandBar_Show(command_bar_handle, TRUE); */
        return 0;

    case WM_SETFOCUS:
        SetFocus(edit_handle);
        return 0;

    case WM_PAINT:
        BeginPaint(hwnd, &ps);
        EndPaint(hwnd, &ps);
        break;

    case WM_CLOSE:
        ShowWindow(main_window_handle, SW_HIDE);
        return 0;

#ifdef WM_SHOWWINDOW
    case WM_SHOWWINDOW:
        visible=(BOOL)wParam;
#else /* this works for Pierre Delaage, but not for me... */
    case WM_WINDOWPOSCHANGED:
        visible=IsWindowVisible(main_window_handle);
#endif
        if(tray_menu_handle)
            CheckMenuItem(tray_menu_handle, IDM_SHOW_LOG,
                visible ? MF_CHECKED : MF_UNCHECKED);
        if(visible)
            update_logs();
#ifdef WM_SHOWWINDOW
        return 0;
#else
        break; /* proceed to DefWindowProc() */
#endif

    case WM_DESTROY:
#ifdef _WIN32_WCE
        CommandBar_Destroy(command_bar_handle);
#else
        if(main_menu_handle) {
            if(!DestroyMenu(main_menu_handle))
                ioerror("DestroyMenu");
            main_menu_handle=NULL;
        }
#endif
        tray_delete(); /* remove the taskbark icon if exists */
        PostQuitMessage(0);
        return 0;

    case WM_COMMAND:
        if(wParam>=IDM_PEER_MENU && wParam<IDM_PEER_MENU+number_of_sections) {
            for(section=service_options.next, section_number=0;
                    section && wParam!=IDM_PEER_MENU+section_number;
                    section=section->next, ++section_number)
                ;
            if(!section)
                return 0;
            if(save_text_file(section->file, section->chain))
                return 0;
#ifndef _WIN32_WCE
            if(main_menu_handle)
                CheckMenuItem(main_menu_handle, (UINT)wParam, MF_CHECKED);
#endif
            if(tray_menu_handle)
                CheckMenuItem(tray_menu_handle, (UINT)wParam, MF_CHECKED);
            message_box(section->help, MB_ICONINFORMATION);
            return 0;
        }
        switch(wParam) {
        case IDM_ABOUT:
            DialogBox(ghInst, TEXT("AboutBox"), main_window_handle,
                (DLGPROC)about_proc);
            break;
        case IDM_SHOW_LOG:
            if(visible) {
                ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            } else {
                ShowWindow(main_window_handle, SW_SHOWNORMAL); /* show window */
                SetForegroundWindow(main_window_handle); /* bring on top */
            }
            break;
        case IDM_CLOSE:
            ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            break;
        case IDM_EXIT:
            if(num_clients>=0) /* signal_pipe is active */
                signal_post(SIGNAL_TERMINATE);
            DestroyWindow(main_window_handle);
            break;
        case IDM_SAVE_LOG:
            if(!cmdline.service) /* security */
                save_log();
            break;
        case IDM_EDIT_CONFIG:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                edit_config(main_window_handle);
#endif
            break;
        case IDM_RELOAD_CONFIG:
            if(num_clients>=0) /* signal_pipe is active */
                signal_post(SIGNAL_RELOAD_CONFIG);
            else
                SetEvent(config_ready); /* unlock daemon_thread() */
            break;
        case IDM_REOPEN_LOG:
            signal_post(SIGNAL_REOPEN_LOG);
            break;
        case IDM_MANPAGE:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                ShellExecute(main_window_handle, TEXT("open"),
                    TEXT("..\\doc\\stunnel.html"), NULL, NULL, SW_SHOWNORMAL);
#endif
            break;
        case IDM_HOMEPAGE:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                ShellExecute(main_window_handle, TEXT("open"),
                    TEXT("http://www.stunnel.org/"), NULL, NULL, SW_SHOWNORMAL);
#endif
            break;
        }
        return 0;

    case WM_SYSTRAY: /* a taskbar event */
        switch(lParam) {
#ifdef _WIN32_WCE
        case WM_LBUTTONDOWN: /* no right mouse button on Windows CE */
            GetWindowRect(GetDesktopWindow(), &rect); /* no cursor position */
            pt.x=rect.right;
            pt.y=rect.bottom-25;
#else
        case WM_RBUTTONDOWN:
            GetCursorPos(&pt);
#endif
            SetForegroundWindow(main_window_handle);
            if(tray_menu_handle)
                TrackPopupMenuEx(GetSubMenu(tray_menu_handle, 0),
                    TPM_BOTTOMALIGN, pt.x, pt.y, main_window_handle, NULL);
            PostMessage(main_window_handle, WM_NULL, 0, 0);
            break;
#ifndef _WIN32_WCE
        case WM_LBUTTONDBLCLK: /* switch log window visibility */
            if(visible) {
                ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            } else {
                ShowWindow(main_window_handle, SW_SHOWNORMAL); /* show window */
                SetForegroundWindow(main_window_handle); /* bring on top */
            }
            break;
#endif
        }
        return 0;

    case WM_VALID_CONFIG:
        valid_config();
        return 0;

    case WM_INVALID_CONFIG:
        invalid_config();
        return 0;

    case WM_LOG:
        txt=(LPTSTR)wParam;
        win_log(txt);
        str_free(txt);
        return 0;

    case WM_NEW_CHAIN:
#ifndef _WIN32_WCE
        if(main_menu_handle)
            EnableMenuItem(main_menu_handle,
                (UINT)(IDM_PEER_MENU+wParam), MF_ENABLED);
#endif
        if(tray_menu_handle)
            EnableMenuItem(tray_menu_handle,
                (UINT)(IDM_PEER_MENU+wParam), MF_ENABLED);
        return 0;

    case WM_CLIENTS:
        tray_update((int)wParam);
        return 0;
    }

    return DefWindowProc(main_window_handle, message, wParam, lParam);
}
Beispiel #19
0
LRESULT CRhoMapViewDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	SetWindowText(_T("MapView"));

#if defined(_WIN32_WCE) 

#if !defined (OS_PLATFORM_MOTCE)
	SHINITDLGINFO shidi = { SHIDIM_FLAGS, m_hWnd, SHIDIF_SIZEDLGFULLSCREEN };
	RHO_ASSERT(SHInitDialog(&shidi));


	SHMENUBARINFO mbi = { sizeof(mbi), 0 };
	mbi.hwndParent = m_hWnd;
	mbi.nToolBarId = IDR_GETURL_MENUBAR;//IDR_MAPVIEW;
	mbi.hInstRes = _AtlBaseModule.GetResourceInstance();
	
	SHCreateMenuBar(&mbi);
#else
	m_hWndCommandBar = CommandBar_Create(_AtlBaseModule.GetResourceInstance(), m_hWnd, 1);
	CommandBar_AddAdornments(m_hWndCommandBar, 0, 0 );
    CommandBar_Show(m_hWndCommandBar, TRUE);
#endif //OS_WINCE

	//::SetWindowLong(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, 
	//	GWL_EXSTYLE,
	//	::GetWindowLong(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT);


	RECT r;
	::GetClientRect(m_hWnd, &r);

	RHO_MAP_TRACE2("execute rho_map_create( w = %d,  h = %d )", r.right - r.left, r.bottom - r.top);
	ourMapView = rho_map_create(mParams, &ourDrawingDevice, r.right - r.left, r.bottom - r.top);
	rho_param_free(mParams);
	mParams = NULL;


	if (ourMapView != NULL) {
		int minz = ourMapView->minZoom();
		int maxz = ourMapView->maxZoom();
		RHO_MAP_TRACE2("request Zoom limits: minZoom = %d,  maxZoom = %d", minz, maxz);
		::SendMessage(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, TBM_SETRANGEMIN, FALSE, minz); 
		::SendMessage(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, TBM_SETRANGEMAX, FALSE, maxz); 
		int dwPos = ourMapView->zoom();
		dwPos = ourMapView->maxZoom() - (dwPos - ourMapView->minZoom());
		::SendMessage(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, TBM_SETPOS, TRUE, dwPos); 

		String strImagePath = "lib/res/blue_pushpin.png";
		String fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath);
		IDrawingImage* pinImg = ourDrawingDevice.createImage(fullImagePath, true);

        PIN_INFO pin_info = {0};
		pin_info.x_offset = -10;
		pin_info.y_offset = -35;
		pin_info.click_rect_x = -10;
		pin_info.click_rect_y = -35;
		pin_info.click_rect_width = 72;
		pin_info.click_rect_height = 72;

		ourMapView->setPinImage(pinImg, pin_info);

		strImagePath = "lib/res/callout.png";
		fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath);
		IDrawingImage* pinCalloutImg = ourDrawingDevice.createImage(fullImagePath, true);

        PIN_INFO pin_callout_info = {0};
		pin_callout_info.x_offset = 5;
		pin_callout_info.y_offset = 0;
		pin_callout_info.click_rect_width = 179;
		pin_callout_info.click_rect_height = 64;

		ourMapView->setPinCalloutImage(pinCalloutImg, pin_callout_info);

		strImagePath = "lib/res/callout_link.png";
		fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath);
		IDrawingImage* pinCalloutLinkImg = ourDrawingDevice.createImage(fullImagePath, true);
		ourMapView->setPinCalloutLinkImage(pinCalloutLinkImg, pin_callout_info);

		strImagePath = "lib/res/esri.png";
		fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath);
		IDrawingImage* esriLogoImg = ourDrawingDevice.createImage(fullImagePath, true);
		ourMapView->setESRILogoImage(esriLogoImg);
	}

#else 

	//CreateButtons();
	//GotoDlgCtrl(m_btnOk);

#endif

	requestRedraw();

	return FALSE;
}
Beispiel #20
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	TCHAR szHello[MAX_LOADSTRING];

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_FORMAT_CELLS:
					PROPSHEETHEADER psh;
					PROPSHEETPAGE psp1;
					HPROPSHEETPAGE hpsp[2];
					
					memset(&psh, 0, sizeof(PROPSHEETHEADER));
					memset(&psp1, 0, sizeof(PROPSHEETPAGE));
					//create two property sheet pages and their property sheet
					psp1.dwSize=sizeof(psp1);
					psp1.pszTitle = _T("Size");
					psp1.dwFlags=PSP_DEFAULT | PSP_USETITLE;
					psp1.hInstance=hInst;
					psp1.pszTemplate=MAKEINTRESOURCE(IDD_FORMAT_CELLS);
					psp1.pfnDlgProc=(DLGPROC)PropPageProc1;
					hpsp[0]=CreatePropertySheetPage(&psp1);
        
					psh.dwSize=sizeof(psh);
					psh.dwFlags=PSH_USEICONID;
					psh.hwndParent=hWnd;
					psh.pfnCallback = NULL;
					psh.hInstance=hInst;
					psh.pszIcon=TEXT("IDI_PROP1");
					psh.pszCaption=TEXT("PROP1");
					psh.phpage=hpsp;
					psh.nPages=1;
					psh.nStartPage=0;
					PropertySheet(&psh);
				    break;
				case IDM_HELP_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_FILE_EXIT:
				   DestroyWindow(hWnd);
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			hwndCB = CommandBar_Create(hInst, hWnd, 1);			
			CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
			CommandBar_AddAdornments(hwndCB, 0, 0);
			break;
		case WM_PAINT:
			RECT rt;
			hdc = BeginPaint(hWnd, &ps);
			GetClientRect(hWnd, &rt);
			LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
			DrawText(hdc, szHello, _tcslen(szHello), &rt, 
				DT_SINGLELINE | DT_VCENTER | DT_CENTER);
			EndPaint(hWnd, &ps);
			break;
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Beispiel #21
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_HELP_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_FILE_EXIT:
				   DestroyWindow(hWnd);
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			hwndCB = CommandBar_Create(hInst, hWnd, 1);			
			CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
			CommandBar_AddAdornments(hwndCB, 0, 0);
			break;
		case WM_PAINT:
		{
			hdc = BeginPaint(hWnd, &ps);
			HDC hdcBitmap;
			HBITMAP hbm, hbmOld;
			HBRUSH hbr, hbrOld;
			int cyCB = CommandBar_Height(hwndCB);

			// Create bitmap & DC.
			{
				hdcBitmap = CreateCompatibleDC(hdc);
				hbm = CreateCompatibleBitmap(hdc, 100, 100);
				hbmOld = SelectBitmap(hdcBitmap, hbm);        // windowsx.h macro
			}

			// Draw into bitmap and copy bitmap to drawing surface.
			{
				SelectObject(hdcBitmap, GetStockObject(GRAY_BRUSH));
				Rectangle(hdcBitmap, 0, 0, 100, 100);

				SelectObject(hdcBitmap, GetStockObject(WHITE_BRUSH));
				Rectangle(hdcBitmap, 20, 20, 80, 80);

				SelectObject(hdcBitmap, GetStockObject(BLACK_BRUSH));
				Rectangle(hdcBitmap, 40, 40, 60, 60);

				SetTextColor(hdcBitmap, RGB(255, 0, 0));
				ExtTextOut(hdcBitmap, 5, 5, 0, NULL, TEXT("Hello World"), 11, NULL);

				BitBlt(hdc, 0, cyCB, 100, 100, hdcBitmap, 0, 0, SRCCOPY);

			}

			// Cleanup bitmap & DC.
			{
				SelectObject(hdc, hbmOld);
				DeleteDC(hdcBitmap);
				DeleteObject(hbm);
			}

			// Fill an area with a blue brush.
			hbr = CreateSolidBrush(RGB(0, 0, 255));
			hbrOld = SelectBrush(hdc, hbr);  // windowsx.h macro
			BitBlt(hdc, 10,  cyCB+110, 80, 20, NULL, 0, 0, PATCOPY);
			SelectObject(hdc, hbrOld);
			DeleteObject(hbr);

			BitBlt(hdc, 20, cyCB+140, 40, 40, NULL, 0, 0, BLACKNESS);
			BitBlt(hdc, 30, cyCB+150, 20, 20, NULL, 0, 0, WHITENESS);
			EndPaint(hWnd, &ps);
		}
			break;
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Beispiel #22
0
/*
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
*/
LRESULT CALLBACK
MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PNHMainWindow data;

    switch (message) {
    /*-----------------------------------------------------------------------*/
    case WM_CREATE: {
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
        SHMENUBARINFO menubar;
#endif
        /* set window data */
        data = (PNHMainWindow) malloc(sizeof(NHMainWindow));
        if (!data)
            panic("out of memory");
        ZeroMemory(data, sizeof(NHMainWindow));
        data->mapAcsiiModeSave = MAP_MODE_ASCII12x16;
        SetWindowLong(hWnd, GWL_USERDATA, (LONG) data);

        GetNHApp()->hMainWnd = hWnd;

/* create menu bar */
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
        ZeroMemory(&menubar, sizeof(menubar));
        menubar.cbSize = sizeof(menubar);
        menubar.hwndParent = hWnd;
        menubar.dwFlags = 0;
        menubar.nToolBarId = IDC_WINHACK;
        menubar.hInstRes = GetNHApp()->hApp;
#if defined(WIN_CE_POCKETPC)
        menubar.nBmpId = IDB_MENUBAR;
        menubar.cBmpImages = 2;
#else
        menubar.nBmpId = 0;
        menubar.cBmpImages = 0;
#endif
        if (!SHCreateMenuBar(&menubar))
            panic("cannot create menu");
        GetNHApp()->hMenuBar = menubar.hwndMB;
#else
        GetNHApp()->hMenuBar = CommandBar_Create(GetNHApp()->hApp, hWnd, 1);
        if (!GetNHApp()->hMenuBar)
            panic("cannot create menu");
        CommandBar_InsertMenubar(GetNHApp()->hMenuBar, GetNHApp()->hApp,
                                 IDC_WINHACK, 0);
#endif
        CheckMenuItem(
            _get_main_menu(ID_VIEW), IDM_VIEW_KEYPAD,
            MF_BYCOMMAND | (GetNHApp()->bCmdPad ? MF_CHECKED : MF_UNCHECKED));

    } break;

    /*-----------------------------------------------------------------------*/

    case WM_MSNH_COMMAND:
        onMSNHCommand(hWnd, wParam, lParam);
        break;

    /*-----------------------------------------------------------------------*/

    case WM_KEYDOWN:
        data = (PNHMainWindow) GetWindowLong(hWnd, GWL_USERDATA);

        /* translate arrow keys into nethack commands */
        switch (wParam) {
        case VK_LEFT:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line left */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_LINEUP, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_W));
            }
            return 0;

        case VK_RIGHT:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line right */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_LINEDOWN, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_E));
            }
            return 0;

        case VK_UP:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line up */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_LINEUP, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_N));
            }
            return 0;

        case VK_DOWN:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line down */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_LINEDOWN, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_S));
            }
            return 0;

        case VK_HOME:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window to upper left corner */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, 0), (LPARAM) NULL);

                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_NW));
            }
            return 0;

        case VK_END:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window to lower right corner */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, ROWNO), (LPARAM) NULL);

                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, COLNO), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_SW));
            }
            return 0;

        case VK_PRIOR:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one page up */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_PAGEUP, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_NE));
            }
            return 0;

        case VK_NEXT:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one page down */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_PAGEDOWN, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_SE));
            }
            return 0;

        case VK_DECIMAL:
        case VK_DELETE:
            NHEVENT_KBD(KEYTABLE(KEY_WAITLOOK));
            return 0;

        case VK_INSERT:
            NHEVENT_KBD(KEYTABLE(KEY_INV));
            return 0;

        case VK_SUBTRACT:
            NHEVENT_KBD(KEYTABLE(KEY_MINUS));
            return 0;

        case VK_ADD:
            NHEVENT_KBD(KEYTABLE(KEY_PLUS));
            return 0;

        case VK_CLEAR: /* This is the '5' key */
            NHEVENT_KBD(KEYTABLE(KEY_GOINTERESTING));
            return 0;

        case VK_F4:
            if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
                mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                          ? data->mapAcsiiModeSave
                                          : MAP_MODE_TILES);
            } else {
                mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                          ? MAP_MODE_ASCII_FIT_TO_SCREEN
                                          : MAP_MODE_TILES_FIT_TO_SCREEN);
            }
            return 0;

        case VK_F5:
            if (IS_MAP_ASCII(iflags.wc_map_mode)) {
                if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
                    mswin_select_map_mode(MAP_MODE_TILES_FIT_TO_SCREEN);
                } else {
                    mswin_select_map_mode(MAP_MODE_TILES);
                }
            } else {
                if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
                    mswin_select_map_mode(MAP_MODE_ASCII_FIT_TO_SCREEN);
                } else {
                    mswin_select_map_mode(data->mapAcsiiModeSave);
                }
            }
            return 0;

        case VK_RETURN: {
            int x, y;
            if (WIN_MAP != WIN_ERR) {
                mswin_map_get_cursor(mswin_hwnd_from_winid(WIN_MAP), &x, &y);
            } else {
                x = u.ux;
                y = u.uy;
            }
            NHEVENT_MS(CLICK_1, x, y);
        }
            return 0;
        }

#if defined(WIN_CE_SMARTPHONE)
        if (GetNHApp()->bCmdPad
            && NHSPhoneTranslateKbdMessage(wParam, lParam, TRUE))
            return 0;
#endif
        return 1; /* end of WM_KEYDOWN */

/*-----------------------------------------------------------------------*/

#if defined(WIN_CE_SMARTPHONE)
    case WM_KEYUP:
        if (GetNHApp()->bCmdPad
            && NHSPhoneTranslateKbdMessage(wParam, lParam, FALSE))
            return 0;
        return 1; /* end of WM_KEYUP */
#endif
    /*-----------------------------------------------------------------------*/

    case WM_CHAR:
#if defined(WIN_CE_SMARTPHONE)
        /* if smartphone cmdpad is up then translation happens - disable
           WM_CHAR processing
           to avoid double input */
        if (GetNHApp()->bCmdPad) {
            return 1;
        }
#endif

        if (wParam == '\n' || wParam == '\r' || wParam == C('M'))
            return 0; /* we already processed VK_RETURN */

        /* all characters go to nethack except Ctrl-P that scrolls message
         * window up */
        if (wParam == C('P') || wParam == C('p')) {
            SendMessage(mswin_hwnd_from_winid(WIN_MESSAGE), WM_VSCROLL,
                        MAKEWPARAM(SB_LINEUP, 0), (LPARAM) NULL);
        } else {
            NHEVENT_KBD((lParam & 1 << 29) ? M(tolower(wParam)) : wParam);
        }
        return 0;

    /*-----------------------------------------------------------------------*/

    case WM_COMMAND:
        /* process commands - menu commands mostly */
        if (IsWindow(GetNHApp()->hPopupWnd)) {
            return SendMessage(GetNHApp()->hPopupWnd, message, wParam,
                               lParam);
        } else if (onWMCommand(hWnd, wParam, lParam))
            return DefWindowProc(hWnd, message, wParam, lParam);
        else
            return 0;

    /*-----------------------------------------------------------------------*/

    case WM_ACTIVATE:
        if (LOWORD(wParam) != WA_INACTIVE) {
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
            if (GetNHApp()->bFullScreen)
                SHFullScreen(GetNHApp()->hMainWnd,
                             SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
            else
                SHFullScreen(GetNHApp()->hMainWnd,
                             SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON);
#endif
            mswin_layout_main_window(NULL);
        }
        break;

    case WM_SETTINGCHANGE:
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
        if (GetNHApp()->bFullScreen)
            SHFullScreen(GetNHApp()->hMainWnd,
                         SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
        else
            SHFullScreen(GetNHApp()->hMainWnd,
                         SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON);
#endif
        mswin_layout_main_window(NULL);
        break;

    case WM_SIZE:
        mswin_layout_main_window(NULL);
        break;

    /*-----------------------------------------------------------------------*/

    case WM_SETFOCUS:
        /* if there is a menu window out there -
           transfer input focus to it */
        if (IsWindow(GetNHApp()->hPopupWnd)) {
            SetFocus(GetNHApp()->hPopupWnd);
        }
        break;

    /*-----------------------------------------------------------------------*/

    case WM_CLOSE: {
/* exit gracefully */
#ifdef SAFERHANGUP
        /* destroy popup window - it has its own loop and we need to
           return control to NetHack core at this point */
        if (IsWindow(GetNHApp()->hPopupWnd))
            SendMessage(GetNHApp()->hPopupWnd, WM_COMMAND, IDCANCEL, 0);

        /* tell NetHack core that "hangup" is requested */
        hangup(1);
#else
        dosave0();
        terminate(EXIT_SUCCESS);
#endif
    }
        return 0;

    /*-----------------------------------------------------------------------*/

    case WM_DESTROY: {
        /* apparently we never get here
           TODO: work on exit routines - need to send
           WM_QUIT somehow */

        /* clean up */
        free((PNHMainWindow) GetWindowLong(hWnd, GWL_USERDATA));
        SetWindowLong(hWnd, GWL_USERDATA, (LONG) 0);

        terminate(EXIT_SUCCESS);
    } break;

    /*-----------------------------------------------------------------------*/

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Beispiel #23
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

#if defined(SHELL_AYGSHELL) && !defined(WIN32_PLATFORM_WFSP)
    static SHACTIVATEINFO s_sai;
#endif // SHELL_AYGSHELL && !WIN32_PLATFORM_WFSP
	
    switch (message) 
    {
        case WM_COMMAND:
            wmId    = LOWORD(wParam); 
            wmEvent = HIWORD(wParam); 
            // Parse the menu selections:
            switch (wmId)
            {
#ifndef WIN32_PLATFORM_WFSP
                case IDM_HELP_ABOUT:
                    DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About);
                    break;
#endif // !WIN32_PLATFORM_WFSP
#ifndef SHELL_AYGSHELL
                case IDM_FILE_EXIT:
                    DestroyWindow(hWnd);
                    break;
#endif // !SHELL_AYGSHELL
#ifdef WIN32_PLATFORM_WFSP
                case IDM_OK:
                    DestroyWindow(hWnd);
                    break;
#endif // WIN32_PLATFORM_WFSP
#ifdef WIN32_PLATFORM_PSPC
                case IDM_OK:
                    SendMessage (hWnd, WM_CLOSE, 0, 0);				
                    break;
#endif // WIN32_PLATFORM_PSPC
                default:
                    return DefWindowProc(hWnd, message, wParam, lParam);
            }
            break;
        case WM_CREATE:
#ifndef SHELL_AYGSHELL
            g_hWndCommandBar = CommandBar_Create(g_hInst, hWnd, 1);
            CommandBar_InsertMenubar(g_hWndCommandBar, g_hInst, IDR_MENU, 0);
            CommandBar_AddAdornments(g_hWndCommandBar, 0, 0);
#endif // !SHELL_AYGSHELL
#ifdef SHELL_AYGSHELL
            SHMENUBARINFO mbi;

            memset(&mbi, 0, sizeof(SHMENUBARINFO));
            mbi.cbSize     = sizeof(SHMENUBARINFO);
            mbi.hwndParent = hWnd;
            mbi.nToolBarId = IDR_MENU;
            mbi.hInstRes   = g_hInst;

            if (!SHCreateMenuBar(&mbi)) 
            {
                g_hWndMenuBar = NULL;
            }
            else
            {
                g_hWndMenuBar = mbi.hwndMB;
            }

#ifndef WIN32_PLATFORM_WFSP
            // Initialize the shell activate info structure
            memset(&s_sai, 0, sizeof (s_sai));
            s_sai.cbSize = sizeof (s_sai);
#endif // !WIN32_PLATFORM_WFSP
#endif // SHELL_AYGSHELL
            break;
        case WM_PAINT:
            hdc = BeginPaint(hWnd, &ps);
            
            // TODO: Add any drawing code here...
            
            EndPaint(hWnd, &ps);
            break;
        case WM_DESTROY:
#ifndef SHELL_AYGSHELL
            CommandBar_Destroy(g_hWndCommandBar);
#endif // !SHELL_AYGSHELL
#ifdef SHELL_AYGSHELL
            CommandBar_Destroy(g_hWndMenuBar);
#endif // SHELL_AYGSHELL
            PostQuitMessage(0);
            break;

#if defined(SHELL_AYGSHELL) && !defined(WIN32_PLATFORM_WFSP)
        case WM_ACTIVATE:
            // Notify shell of our activate message
            SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
            break;
        case WM_SETTINGCHANGE:
            SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
            break;
#endif // SHELL_AYGSHELL && !WIN32_PLATFORM_WFSP

        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}