Esempio n. 1
0
void wxVListBox::OnPaint(wxPaintEvent& WXUNUSED(event))
{
    wxSize clientSize = GetClientSize();

    wxAutoBufferedPaintDC dc(this);

    // the update rectangle
    wxRect rectUpdate = GetUpdateClientRect();

    // fill it with background colour
    dc.SetBackground(GetBackgroundColour());
    dc.Clear();

    // the bounding rectangle of the current line
    wxRect rectLine;
    rectLine.width = clientSize.x;

    // iterate over all visible lines
    const size_t lineMax = GetVisibleEnd();
    for ( size_t line = GetFirstVisibleLine(); line < lineMax; line++ )
    {
        const wxCoord hLine = OnGetLineHeight(line);

        rectLine.height = hLine;

        // and draw the ones which intersect the update rect
        if ( rectLine.Intersects(rectUpdate) )
        {
            // don't allow drawing outside of the lines rectangle
            wxDCClipper clip(dc, rectLine);

            wxRect rect = rectLine;
            OnDrawBackground(dc, rect, line);

            OnDrawSeparator(dc, rect, line);

            rect.Deflate(m_ptMargins.x, m_ptMargins.y);
            OnDrawItem(dc, rect, line);
        }
        else // no intersection
        {
            if ( rectLine.GetTop() > rectUpdate.GetBottom() )
            {
                // we are already below the update rect, no need to continue
                // further
                break;
            }
            //else: the next line may intersect the update rect
        }

        rectLine.y += hLine;
    }
}
Esempio n. 2
0
void wxVListBoxComboPopup::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
{
    // TODO: Maybe this code could be moved to wxVListBox::OnPaint?
    dc.SetFont(m_useFont);

    // Set correct text colour for selected items
    if ( wxVListBox::GetSelection() == (int) n )
        dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
    else
        dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );

    OnDrawItem(dc,rect,(int)n,0);
}
Esempio n. 3
0
HRESULT CWorkshareMenu::MenuMessageHandler( UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pResult )
{
	switch ( uMsg )
	{
	case WM_MEASUREITEM:
		return OnMeasureItem( (MEASUREITEMSTRUCT*) lParam, pResult );
		break;

	case WM_DRAWITEM:
		return OnDrawItem( (DRAWITEMSTRUCT*) lParam, pResult );
		break;
	}
	return S_OK;
}
Esempio n. 4
0
STDMETHODIMP CBmpCtxMenuExt::MenuMessageHandler ( UINT uMsg, WPARAM wParam,
                                                  LPARAM lParam, LRESULT* pResult )
{
    switch ( uMsg )
        {
        case WM_MEASUREITEM:
            {
            return OnMeasureItem ( (MEASUREITEMSTRUCT*) lParam, pResult );
            }
        break;

        case WM_DRAWITEM:
            {
            return OnDrawItem ( (DRAWITEMSTRUCT*) lParam, pResult );
            }
        break;
        }

    return S_OK;
}
Esempio n. 5
0
// paint the control itself
void wxVListBoxComboPopup::PaintComboControl( wxDC& dc, const wxRect& rect )
{
    if ( !(m_combo->GetWindowStyle() & wxODCB_STD_CONTROL_PAINT) )
    {
        int flags = wxODCB_PAINTING_CONTROL;

        if ( m_combo->ShouldDrawFocus() )
            flags |= wxODCB_PAINTING_SELECTED;

        OnDrawBg(dc, rect, m_value, flags);

        if ( m_value >= 0 )
        {
            OnDrawItem(dc,rect,m_value,flags);
            return;
        }
    }

    wxComboPopup::PaintComboControl(dc,rect);
}
Esempio n. 6
0
void wxVListBoxComboPopup::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
{
    // TODO: Maybe this code could be moved to wxVListBox::OnPaint?
    dc.SetFont(m_useFont);

    int flags = 0;

    // Set correct text colour for selected items
    if ( wxVListBox::GetSelection() == (int) n )
    {
        dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
        flags |= wxODCB_PAINTING_SELECTED;
    }
    else
    {
        dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
    }

    OnDrawItem(dc,rect,(int)n,flags);
}
Esempio n. 7
0
//////////////////
// Virtual CSubclassWnd window proc. All messages come here before frame
// window. Isn't it cool? Just like in the old days!
//
LRESULT CCoolMenuManager::WindowProc(UINT msg, WPARAM wp, LPARAM lp)
{
	switch(msg) {
	case WM_SYSCOLORCHANGE:
	case WM_SETTINGCHANGE:
		Refresh();
		break;

	case WM_MEASUREITEM:
		if (OnMeasureItem((MEASUREITEMSTRUCT*)lp))
			return TRUE; // handled
		break;

	case WM_DRAWITEM:
		if (OnDrawItem((DRAWITEMSTRUCT*)lp))
			return TRUE; // handled
		break;

	case WM_INITMENUPOPUP:
		// Very important: must let frame window handle it first!
		// Because if someone calls CCmdUI::SetText, MFC will change item to
		// MFT_STRING, so I must change back to MFT_OWNERDRAW.
		//
		CSubclassWnd::WindowProc(msg, wp, lp);
		OnInitMenuPopup(CMenu::FromHandle((HMENU)wp),
			(UINT)LOWORD(lp), (BOOL)HIWORD(lp));
		return 0;

	case WM_MENUSELECT:
		OnMenuSelect((UINT)LOWORD(wp), (UINT)HIWORD(wp), (HMENU)lp);
		break;
	
	case WM_MENUCHAR:
		LRESULT lr = OnMenuChar((TCHAR)LOWORD(wp), (UINT)HIWORD(wp),
			CMenu::FromHandle((HMENU)lp));
		if (lr!=0)
			return lr;
		break;
	}
	return CSubclassWnd::WindowProc(msg, wp, lp);
}
Esempio n. 8
0
bool CChannelMenu::HandleMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam,LRESULT *pResult)
{
	if (m_hwnd==NULL || hwnd!=m_hwnd)
		return false;

	switch (uMsg) {
	case WM_MEASUREITEM:
		if (OnMeasureItem(hwnd,wParam,lParam)) {
			*pResult=TRUE;
			return true;
		}
		break;

	case WM_DRAWITEM:
		if (OnDrawItem(hwnd,wParam,lParam)) {
			*pResult=TRUE;
			return true;
		}
		break;

	case WM_UNINITMENUPOPUP:
		if (OnUninitMenuPopup(hwnd,wParam,lParam)) {
			*pResult=0;
			return true;
		}
		break;

	case WM_MENUSELECT:
		if (OnMenuSelect(hwnd,wParam,lParam)) {
			*pResult=0;
			return true;
		}
		break;
	}

	return false;
}
Esempio n. 9
0
/*------------------------------------------------
  dialog procedure
--------------------------------------------------*/
INT_PTR CALLBACK DlgProcSelectIcon(HWND hDlg, UINT message,
	WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
		case WM_INITDIALOG:
			if(!InitSelectIcon(hDlg))
				EndDialog(hDlg, IDCANCEL);
			return TRUE;
		case WM_MEASUREITEM:
			OnMeasureItem(hDlg, lParam);
			return TRUE;
		case WM_DRAWITEM:
			OnDrawItem(lParam);
			return TRUE;
		case WM_COMMAND:
		{
			WORD id;
			id = LOWORD(wParam);
			switch(id)
			{
				case IDC_SANSHOICON:
					OnBrowse(hDlg);
					break;
				case IDOK:
					OnOK(hDlg);
				case IDCANCEL:
					EndSelectIcon(hDlg);
					EndDialog(hDlg, id);
					break;
			}
			return TRUE;
		}
	}
	return FALSE;
}
void wxSymbolListCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
{
    // If size is larger, recalculate double buffer bitmap
    wxSize clientSize = GetClientSize();

    if ( !m_doubleBuffer ||
         clientSize.x > m_doubleBuffer->GetWidth() ||
         clientSize.y > m_doubleBuffer->GetHeight() )
    {
        delete m_doubleBuffer;
        m_doubleBuffer = new wxBitmap(clientSize.x+25,clientSize.y+25);
    }

    wxBufferedPaintDC dc(this,*m_doubleBuffer);

    // the update rectangle
    wxRect rectUpdate = GetUpdateClientRect();

    // fill it with background colour
    dc.SetBackground(GetBackgroundColour());
    dc.Clear();

    // set the font to be displayed
    dc.SetFont(GetFont());

    // the bounding rectangle of the current line
    wxRect rectRow;
    rectRow.width = clientSize.x;

    dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)));
    dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
    dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);

    // iterate over all visible lines
    const size_t lineMax = GetVisibleEnd();
    for ( size_t line = GetVisibleBegin(); line < lineMax; line++ )
    {
        const wxCoord hRow = OnGetRowHeight(line);

        rectRow.height = hRow;

        // and draw the ones which intersect the update rect
        if ( rectRow.Intersects(rectUpdate) )
        {
            // don't allow drawing outside of the lines rectangle
            wxDCClipper clip(dc, rectRow);

            wxRect rect = rectRow;
            rect.Deflate(m_ptMargins.x, m_ptMargins.y);
            OnDrawItem(dc, rect, line);
        }
        else // no intersection
        {
            if ( rectRow.GetTop() > rectUpdate.GetBottom() )
            {
                // we are already below the update rect, no need to continue
                // further
                break;
            }
            //else: the next line may intersect the update rect
        }

        rectRow.y += hRow;
    }
}
Esempio n. 11
0
/*------------------------------------------------
  Dialog procedure
--------------------------------------------------*/
INT_PTR CALLBACK PageColorProc(HWND hDlg, UINT message,
	WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
		case WM_INITDIALOG:
			OnInit(hDlg);
			return TRUE;
		case WM_COMMAND:
		{
			WORD id, code;
			id = LOWORD(wParam); code = HIWORD(wParam);
			switch(id)
			{
				case IDC_COLBACK:
				case IDC_COLBACK2:
				case IDC_COLFORE:
#if TC_ENABLE_CLOCKDECORATION
				case IDC_COLSHADOW:
#endif
				case IDC_FONT:
				case IDC_FONTSIZE:
					if(code == CBN_SELCHANGE || code == CBN_EDITCHANGE)
					{
						if(id == IDC_FONT) OnFont(hDlg, FALSE);
						SendPSChanged(hDlg);
					}
					break;
				case IDC_CHKCOLOR:
				case IDC_CHKCOLOR2:
					OnCheckColor(hDlg);
					SendPSChanged(hDlg);
					break;
				case IDC_CHOOSECOLBACK:
				case IDC_CHOOSECOLBACK2:
				case IDC_CHOOSECOLFORE:
#if TC_ENABLE_CLOCKDECORATION
				case IDC_CHOOSECOLSHADOW:
#endif
					OnChooseColor(hDlg, id);
					break;
#if TC_ENABLE_CLOCKDECORATION
				case IDC_DECONONE:
				case IDC_DECOSHADOW:
				case IDC_DECOBORDER:
					OnSelectDecoration(hDlg);
					SendPSChanged(hDlg);
					break;
				case IDC_SHADOWRANGE:
					if(code == EN_CHANGE)
						SendPSChanged(hDlg);
					break;
#endif
				case IDC_GRAD1:
				case IDC_GRAD2:
				case IDC_FILLTRAY:
				case IDC_BOLD:
				case IDC_ITALIC:
					SendPSChanged(hDlg);
					break;
			}
			return TRUE;
		}
		case WM_NOTIFY:
			switch(((NMHDR *)lParam)->code)
			{
				case PSN_APPLY: OnApply(hDlg); break;
				case PSN_HELP: MyHelp(GetParent(hDlg), "Color"); break;
			}
			return TRUE;
		case WM_MEASUREITEM:
			// common/combobox.c
			OnMeasureItemColorCombo((LPMEASUREITEMSTRUCT)lParam);
			return TRUE;
		case WM_DRAWITEM:
			OnDrawItem(hDlg, (LPDRAWITEMSTRUCT)lParam);
			return TRUE;
		case WM_DESTROY:
			if(m_hfontb) DeleteObject(m_hfontb);
			if(m_hfonti) DeleteObject(m_hfonti);
			break;
	}
	return FALSE;
}
Esempio n. 12
0
static
INT_PTR
CALLBACK
StartDlgProc(
    HWND hwndDlg,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam)
{
    PSTATE pState;

    /* Retrieve pointer to the state */
    pState = (PSTATE)GetWindowLongPtr (hwndDlg, GWL_USERDATA);

    switch (uMsg)
    {
        case WM_INITDIALOG:
            /* Save pointer to the state */
            pState = (PSTATE)lParam;
            SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pState);

            /* Center the dialog window */
            CenterWindow(hwndDlg);

            EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE);
            return FALSE;

        case WM_DRAWITEM:
            OnDrawItem((LPDRAWITEMSTRUCT)lParam,
                       pState,
                       IDC_STARTLOGO);
            return TRUE;

        case WM_COMMAND:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                switch (LOWORD(wParam))
                {
                    case IDC_RUN:
                        pState->NextPage = DONE;
                        pState->Run = SHELL;
                        EndDialog(hwndDlg, 0);
                        break;

                    case IDC_INSTALL:
                        pState->NextPage = DONE;
                        pState->Run = INSTALLER;
                        EndDialog(hwndDlg, 0);
                        break;

                    case IDOK:
                        pState->NextPage = LOCALEPAGE;
                        EndDialog(hwndDlg, 0);
                        break;

                    default:
                        break;
                }
            }
            break;

        default:
            break;
    }

    return FALSE;
}
Esempio n. 13
0
static
INT_PTR
CALLBACK
LocaleDlgProc(
    HWND hwndDlg,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam)
{
    PSTATE pState;

    /* Retrieve pointer to the state */
    pState = (PSTATE)GetWindowLongPtr (hwndDlg, GWL_USERDATA);

    switch (uMsg)
    {
        case WM_INITDIALOG:
            /* Save pointer to the global state */
            pState = (PSTATE)lParam;
            SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pState);

            /* Center the dialog window */
            CenterWindow (hwndDlg);
            CreateLanguagesList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST));

            EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE);
            return FALSE;

        case WM_DRAWITEM:
            OnDrawItem((LPDRAWITEMSTRUCT)lParam,
                       pState,
                       IDC_LOCALELOGO);
            return TRUE;

        case WM_COMMAND:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                switch (LOWORD(wParam))
                {
                    case IDOK:
                        {
                        LCID NewLcid;
                        INT iCurSel;

                        iCurSel = SendDlgItemMessageW(hwndDlg,
                                                     IDC_LANGUAGELIST,
                                                     CB_GETCURSEL,
                                                     0,
                                                     0);
                if (iCurSel == CB_ERR)
                    break;

                NewLcid = SendDlgItemMessageW(hwndDlg,
                                              IDC_LANGUAGELIST,
                                              CB_GETITEMDATA,
                                              iCurSel,
                                              0);
                if (NewLcid == (LCID)CB_ERR)
                    break;

                            SetThreadLocale(NewLcid);
                            InitializeDefaultUserLocale(&NewLcid);
                        }

                        pState->NextPage = STARTPAGE;
                        EndDialog(hwndDlg, 0);
                        break;

                    default:
                        break;
                }
            }
            break;

        default:
            break;
    }

    return FALSE;
}
//***************************************************************************************
void CBCGPHeaderCtrl::OnPaint()
{
    CPaintDC dc(this); // device context for painting
    CBCGPMemDC memDC (dc, this);
    CDC* pDC = &memDC.GetDC ();

    CRect rectClip;
    dc.GetClipBox (rectClip);

    CRect rectClient;
    GetClientRect (rectClient);

    OnFillBackground (pDC);

    CFont* pOldFont = SelectFont (pDC);
    ASSERT_VALID (pOldFont);

    pDC->SetTextColor (globalData.clrBtnText);
    pDC->SetBkMode (TRANSPARENT);

    CRect rect;
    GetClientRect(rect);

    CRect rectItem;
    int nCount = GetItemCount ();

    int xMax = 0;

    for (int i = 0; i < nCount; i++)
    {
        //------------------
        // Is item pressed?
        //------------------
        CPoint ptCursor;
        ::GetCursorPos (&ptCursor);
        ScreenToClient (&ptCursor);

        HDHITTESTINFO hdHitTestInfo;
        hdHitTestInfo.pt = ptCursor;

        int iHit = (int) SendMessage (HDM_HITTEST, 0, (LPARAM) &hdHitTestInfo);

        BOOL bIsHighlighted = iHit == i && (hdHitTestInfo.flags & HHT_ONHEADER);
        BOOL bIsPressed = m_bIsMousePressed && bIsHighlighted;

        GetItemRect (i, rectItem);

        CRgn rgnClip;
        rgnClip.CreateRectRgnIndirect (&rectItem);
        pDC->SelectClipRgn (&rgnClip);

        //-----------
        // Draw item:
        //-----------
        OnDrawItem (pDC, i, rectItem, bIsPressed, m_nHighlightedItem == i);

        pDC->SelectClipRgn (NULL);

        xMax = max (xMax, rectItem.right);
    }

    //--------------------
    // Draw "tail border":
    //--------------------
    if (nCount == 0)
    {
        rectItem = rect;
        rectItem.right++;
    }
    else
    {
        rectItem.left = xMax;
        rectItem.right = rect.right + 1;
    }

    OnDrawItem (pDC, -1, rectItem, FALSE, FALSE);

    pDC->SelectObject (pOldFont);
}
Esempio n. 15
0
/*------------------------------------------------
   dialog procedure of this page
--------------------------------------------------*/
INT_PTR CALLBACK PageAnalogClockProc(HWND hDlg, UINT message,
	WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
		case WM_INITDIALOG:
			OnInit(hDlg);
			return TRUE;
		case WM_COMMAND:
		{
			WORD id, code;
			id = LOWORD(wParam); code = HIWORD(wParam);
			switch(id)
			{
				case IDC_ANALOGCLOCK:
					OnAnalogClock(hDlg);
					SendPSChanged(hDlg);
					break;
				case IDC_COLHOUR:
				case IDC_COLMIN:
					if(code == CBN_SELCHANGE)
						SendPSChanged(hDlg);
					break;
				case IDC_CHOOSECOLHOUR:
				case IDC_CHOOSECOLMIN:
					OnChooseColor(hDlg, id);
					break;
				case IDC_HOURHANDBOLD:
				case IDC_MINHANDBOLD:
				case IDC_ANALOGPOSLEFT:
				case IDC_ANALOGPOSRIGHT:
				case IDC_ANALOGPOSMIDDLE:
					SendPSChanged(hDlg);
					break;
				case IDC_ANALOGHPOS:
				case IDC_ANALOGVPOS:
				case IDC_ANALOGSIZE:
				case IDC_ANALOGBMP:
					if(code == EN_CHANGE)
						SendPSChanged(hDlg);
					break;
				case IDC_ANALOGBMPBROWSE:
					OnBrowse(hDlg);
					break;
			}
			return TRUE;
		}
		case WM_DRAWITEM:
			OnDrawItem(hDlg, (LPDRAWITEMSTRUCT)lParam);
			return TRUE;
		case WM_MEASUREITEM:
			// common/combobox.c
			OnMeasureItemColorCombo((LPMEASUREITEMSTRUCT)lParam);
			return TRUE;
		case WM_NOTIFY:
			switch(((NMHDR *)lParam)->code)
			{
				case PSN_APPLY: OnApply(hDlg); break;
				case PSN_HELP: MyHelp(GetParent(hDlg), "AnalogClock"); break;
			}
			return TRUE;
	}
	return FALSE;
}
Esempio n. 16
0
BOOL CSonicSkin::OnWndMsg(UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_DRAWITEM:
		{
			return OnDrawItem((LPDRAWITEMSTRUCT)lParam);
		}
		break;
	case WM_CTLCOLORSTATIC:
		{
			return OnCtlColorStatic((HDC)wParam, (HWND)lParam);
		}
		break;
	case WM_CTLCOLORBTN:
		{
			return OnCtlColorBtn((HDC)wParam, (HWND)lParam);
		}
		break;
	case WM_LBUTTONDBLCLK:
		{
			int x = LOWORD(lParam);
			int y = HIWORD(lParam);
			if(y < m_bg.wTitleHeight)
			{
				SendMessage(m_hWnd, WM_NCLBUTTONDBLCLK, HTCAPTION, 0);
				return FALSE;
			}
		}
		break;
	case WM_LBUTTONDOWN:
		{
			int x = LOWORD(lParam);
			int y = HIWORD(lParam);
			if(y < m_bg.wTitleHeight && m_bg.bEnableDrag)
			{
				SendMessage(m_hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
				return FALSE;
			}
		}
		break;
	case WM_NCHITTEST:
		{
			return OnNCHittest(LOWORD(lParam), HIWORD(lParam));
		}
		break;
	// assure the none-border window wont override the tray bar
	case WM_GETMINMAXINFO:
		{
			return OnGetMinMaxInfo((MINMAXINFO *)lParam);
		}
		break;
	case WM_WINDOWPOSCHANGING:
		{
			return OnPosChanging((LPWINDOWPOS)lParam);
		}
		break;
	case WM_WINDOWPOSCHANGED:
		{
			return OnPosChanged((LPWINDOWPOS)lParam);
		}
		break;
	case WM_ERASEBKGND:
		{
			return OnEraseBackground((HDC)wParam);
		}
		break;
	// erase NC paint
	case WM_NCACTIVATE:
		g_UI.SetCallWndProcRet(TRUE);
		return FALSE;
	case WM_NCPAINT:
		SetRgn();
	case WM_NCCALCSIZE:
		g_UI.SetCallWndProcRet(0);
		return FALSE;
	}
	return TRUE;
}
Esempio n. 17
0
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static UINT s_uTaskBarCreated = 0;

	switch(uMsg)
	{
	case WM_CREATE:
		{
			g_hwndMain = hwnd;
			// Register task bar (re)creation in order to reload systray icons after explorer crashes
			s_uTaskBarCreated = RegisterWindowMessage(REGISTER_MESSAGE);

			// Set Icons
			SendMessage(hwnd, WM_SETICON, ICON_BIG, 
				(LONG)(LONG_PTR)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MAIN_ICON), IMAGE_ICON, 
				GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR));

			SendMessage(hwnd, WM_SETICON, ICON_SMALL, 
				(LONG)(LONG_PTR)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MAIN_ICON), IMAGE_ICON, 
				GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR));

			ShowWindow(hwnd, SW_HIDE);

			// Clear the list
			g_IconTray.clear();

			installHookKeyboard();

			// Open the configuration
			if (openConfig() == FALSE)
			{
				uninstallHookKeyboard();
				clearMenuSkin();

				MessageBox(g_hwndMain, L"Configuration file not found or invalid", ERR_MSGBOX_TITLE, NULL);

				PostQuitMessage(0);
				return 0;
			}

			// Retreive the version of Windows (in order to know if it is a win200 or superior)
			windowsVersion = GetWindowsVersion();

			// Initialisation of variables for menus
			InitMenuVars();

			// Add the system tray icons (depends of the configuration)
			ShowTrayIcons();

			// Show loading error messages
			if (g_loadingmessage != NULL) {
				ShowBalloon(ERR_MSGBOX_TITLE, g_loadingmessage, 0, NIIF_ERROR);
				free(g_loadingmessage);
				g_loadingmessage = NULL;
			}

			// Launch application in "autorun" mode
			fireEvent(PROG_EVENT_START);

			FlushMemory();
		}
		break;

	case WM_HOTKEY:
		if( (wParam >= IDH_HOTKEY_MENU) && (wParam <= (IDH_HOTKEY_MENU + g_portal->hotkeys.size()) ) )
		{
			// Detect application item or menu item in order to open a menu or launch the application
			PortalProg* l_sp = g_portal->hotkeys[ wParam - IDH_HOTKEY_MENU ];

			while( l_sp )
			{
				if( l_sp->progs.size() > 0 )
				{
					ShowTrayMenu(l_sp, PORTAL_MENU_HOTKEY);
				}
				else
				{
					l_sp->run(false);
					// Some commands could call quitPortal. In this case g_portal is set to NULL.
					if(g_portal == NULL)
						return 0;
				}
				l_sp = l_sp->nextSameHotkey;
			}
		}
		FlushMemory();
		break;

	case WM_DESTROY:
		{
			quitPortal();
		}
		break;

	case WM_MYTRAYMSG:
		if ((wParam >= IDI_MAIN_ICON) && g_portal && (wParam <= (IDI_MAIN_ICON + g_portal->menus.size())))
		{
			// Find the clicked systray
			int pos = (int)wParam - IDI_MAIN_ICON;
			if( ((UINT)lParam == WM_RBUTTONUP) || ((UINT)lParam == WM_LBUTTONUP) || ((UINT)lParam == WM_MOUSEMOVE) )
			{
				// Left click : minimalist menu
				// Right click : Complete menu (with About/Reload/Quit)
				// Auto Open : Complete menu (like right click) with a automatic dismiss
				int param = PORTAL_MENU_SYSTRAY;
				if((UINT)lParam == WM_RBUTTONUP)
				{
					param = PORTAL_MENU_SYSTRAY_CMD;
				}
				
				if( ((UINT)lParam == WM_MOUSEMOVE) )
				{
					if( (g_portal->menus[pos] != NULL) && (g_portal->menus[pos]->options & PROG_OPTION_AUTOOPEN) )
					{
						param = PORTAL_MENU_SYSTRAY_AUTO;
					}
					else
					{
						return 0;
					}
				}

				// Detect if the icon is for a menu or a application
				if( (g_portal->menus[pos] != NULL) && ( g_portal->menus[pos]->progs.size() > 0 ) )
				{
					ShowTrayMenu(g_portal->menus[pos], param);
					g_currentMenu = pos;
				}
				else if( (g_portal->menus[pos] != NULL) && (g_portal->menus[pos]->progExe != NULL ))
				{
					if((UINT)lParam == WM_LBUTTONUP)
					{
						g_portal->menus[pos]->run(true);
						g_currentMenu = pos;
					}
					else
					{
						ShowTrayMenu(g_portal->menus[pos], param);
						g_currentMenu = pos;
					}
				}
				else
				{
					ShowTrayMenu(NULL, param);
					g_currentMenu = 0;
				}
				FlushMemory();
			}
			else if( (UINT)lParam == NIN_BALLOONUSERCLICK )
			{
				if(g_aboutbaloon)
					checkGuiproVersion();
				FlushMemory();
				return 0;
			}
		}
		break;

	case WM_INITMENUPOPUP :
		OnInitMenuPopup(hwnd, wParam, lParam);
		break;

	case WM_UNINITMENUPOPUP:
		OnUninitMenuPopup(hwnd, wParam, lParam);
		break;

	case WM_MEASUREITEM :
		OnMeasureItem(hwnd, wParam, lParam);
		break;

	case WM_DRAWITEM :
		OnDrawItem(hwnd, wParam, lParam);
		break;

	case WM_MENUCHAR:
		return OnMenuCharItem(hwnd, wParam, lParam);

	case WM_COMMAND:
		// Retreive a menu command
		if( wParam == IDM_EXIT )
		{
			quitPortal();
		}
		else if( wParam == IDM_RELOAD )
		{
			reloadPortalConfig();
		}
		else if( wParam == IDM_ABOUT )
		{
			ShowAbout(g_currentMenu);
			FlushMemory();
		}
		else if( ((UINT)wParam >= (PORTAL_HK_ID)) && ( (UINT)wParam <= (UINT)(PORTAL_HK_ID + menuGetNbElem()) )  )
		{
			PortalProg* l_sp = menuGetElem( (int)(wParam - 1 - PORTAL_HK_ID) );
			l_sp->run(true);
			FlushMemory();
		}
		else if( ((UINT)wParam >= (PORTAL_FILE_ID)) && ( (UINT)wParam < (UINT)(PORTAL_FILE_ID + menuGetNbFiles()) ) )
		{
			PortalProg* l_sp = menuGetFile( (int)(wParam - PORTAL_FILE_ID) );
			l_sp->run(true);
			FlushMemory();

			for(PortalProgVector::iterator i = g_portal_files.begin(); i != g_portal_files.end(); i++)
			{
				delete (*i);
			}
			g_portal_files.clear();
		}
		break;

	default:
		if( uMsg == s_uTaskBarCreated )
		{
			// Traskbar (re)creation, we have to reset systray icons
			ReloadTrayIcons();
			FlushMemory();
		}
		else
		{
			return(DefWindowProc(hwnd, uMsg, wParam, lParam));
		}
		break;
	}
	return 0;
}
	//--------------------------------------------------------------------------------
	bool CWinCtrlParentController::ProcessMessage( COSWindow& Window, Cmp_long_ptr& lResult, unsigned int uMsg, Cmp_uint_ptr wParam, Cmp_long_ptr lParam )
	{
		_WINQ_FCONTEXT( "CWinCtrlParentController:ProcessMessage" );
		bool bProcessed = ProcessHook( Window, lResult, uMsg, wParam, lParam );

		switch ( uMsg )
		{
		case COSWindow::wmCtlColorMsgBox:
			{
				CDeviceContext::refType refDC = CDeviceContext::FromHandle( CDCHandle( (CDCInternal*)0, (void*)( wParam ) ).Ref() );
				COSWindow::refType refMsgBox = COSWindow::FromHandle( CWindowHandle( 0, (void*)(lParam ) ).Ref() );
				lResult = reinterpret_cast< long >( OnCtlColourMsgBox( Window, refDC, refMsgBox )->Handle()->AsHandle().ptr() );
				bProcessed = true;
			}
			break;
		case COSWindow::wmCtlColorEdit:
			{
				CDeviceContext::refType refDC = CDeviceContext::FromHandle( CDCHandle( (CDCInternal*)0, (void*)( wParam ) ).Ref() );
				COSWindow::refType refEdit = COSWindow::FromHandle( CWindowHandle( 0, (void*)(lParam ) ).Ref() );
				lResult = reinterpret_cast< long >( OnCtlColour( Window, refDC, refEdit, COSWindow::wmCtlColorEdit )->Handle()->AsHandle().ptr() );
				bProcessed = true;
			}
			break;
		case COSWindow::wmCtlColorListBox:
			{
				CDeviceContext::refType refDC = CDeviceContext::FromHandle( CDCHandle( (CDCInternal*)0, (void*)( wParam ) ).Ref() );
				COSWindow::refType refListBox = COSWindow::FromHandle( CWindowHandle( 0, (void*)(lParam ) ).Ref() );
				lResult = reinterpret_cast< long >( OnCtlColour( Window, refDC, refListBox, COSWindow::wmCtlColorListBox )->Handle()->AsHandle().ptr() );
				bProcessed = true;
			}
			break;
		case COSWindow::wmCtlColorBtn:
			{
				CDeviceContext::refType refDC = CDeviceContext::FromHandle( CDCHandle( (CDCInternal*)0, (void*)( wParam ) ).Ref() );
				COSWindow::refType refButton = COSWindow::FromHandle( CWindowHandle( 0, (void*)(lParam ) ).Ref() );
				lResult = reinterpret_cast< long >( OnCtlColour( Window, refDC, refButton, COSWindow::wmCtlColorBtn )->Handle()->AsHandle().ptr() );
				bProcessed = true;
			}
			break;
		case COSWindow::wmCtlColorDlg:
			{
				CDeviceContext::refType refDC = CDeviceContext::FromHandle( CDCHandle( (CDCInternal*)0, (void*)( wParam ) ).Ref() );
				COSWindow::refType refDlg = COSWindow::FromHandle( CWindowHandle( 0, (void*)(lParam ) ).Ref() );
				lResult = reinterpret_cast< long >( OnCtlColourDialog( Window, refDC, refDlg )->Handle()->AsHandle().ptr() );
				bProcessed = true;
			}
			break;
		case COSWindow::wmCtlColorScrollbar:
			{
				CDeviceContext::refType refDC = CDeviceContext::FromHandle( CDCHandle( (CDCInternal*)0, (void*)( wParam ) ).Ref() );
				COSWindow::refType refScrollBar = COSWindow::FromHandle( CWindowHandle( 0, (void*)(lParam ) ).Ref() );
				lResult = reinterpret_cast< long >( OnCtlColour( Window, refDC, refScrollBar, COSWindow::wmCtlColorStatic )->Handle()->AsHandle().ptr() );
				bProcessed = true;
			}
			break;
		case COSWindow::wmCtlColorStatic:
			{
				CDeviceContext::refType refDC = CDeviceContext::FromHandle( CDCHandle( (CDCInternal*)0, (void*)( wParam ) ).Ref() );
				COSWindow::refType refStatic = COSWindow::FromHandle( CWindowHandle( 0, (void*)(lParam ) ).Ref() );
				lResult = reinterpret_cast< long >( OnCtlColour( Window, refDC, refStatic, COSWindow::wmCtlColorStatic )->Handle()->AsHandle().ptr() );
				bProcessed = true;
			}
			break;
		case COSWindow::wmDrawItem:
			{
					DrawItemStruct* pItemStruct = reinterpret_cast< DrawItemStruct* >( lParam );
					OnDrawItem( Window, wParam, pItemStruct );
					lResult = 1;
					bProcessed = true;
			}
			break;
		case COSWindow::wmCompareItem:
			{
				lResult = OnCompareItem( Window, wParam, reinterpret_cast< ComparisonItem* >( lParam ) );					
				bProcessed = true;
			}
			break;
		case COSWindow::wmMeasureItem:
			{
				nsWin32::MeasureItemStruct* pItemStruct = reinterpret_cast< nsWin32::MeasureItemStruct* >( lParam );
				OnMeasureItem( Window, wParam, pItemStruct );
				lResult = 1;
				bProcessed = true;
			}
			break;
		case COSWindow::wmDeleteItem:
			{
				nsWin32::DeleteItemStruct* pItemStruct = reinterpret_cast< nsWin32::DeleteItemStruct* >( lParam );
				OnDeleteItem( Window, wParam, pItemStruct );
				lResult = 1;
				bProcessed = true;
			}
			break;
		case COSWindow::wmVKeyToItem:
			{
				unsigned short wVKey = LoWord( wParam );
				unsigned short wPos = HiWord( wParam );
				COSWindow::refType refListBox = COSWindow::FromHandle( CWindowHandle( 0, (void*)( lParam ) ).Ref() );
				lResult = OnVKeyToItem( Window, wVKey, wPos, refListBox );
				bProcessed = true;
			}
			break;
		case COSWindow::wmCharToItem:
			{
				unsigned short wKey = LoWord( wParam );
				unsigned short wPos = HiWord( wParam );
				COSWindow::refType refListBox = COSWindow::FromHandle( CWindowHandle( 0, (void*)( lParam ) ).Ref() );
				lResult = OnCharToItem( Window, wKey, wPos, refListBox );
				bProcessed = true;
			}
			break;
		}			

		return bProcessed;
	}