示例#1
0
LRESULT CALLBACK ChatView::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
    PAINTSTRUCT ps;
    HDC hdc;
    ChatView *p=(ChatView *) GetWindowLong(hWnd, GWL_USERDATA);

    switch (message) {
    case WM_CREATE:
        {
            p=(ChatView *) (((CREATESTRUCT *)lParam)->lpCreateParams);
            SetWindowLong(hWnd, GWL_USERDATA, (LONG) p );

            p->msgList=VirtualListView::ref(new VirtualListView(hWnd, std::string("Chat")));
            p->msgList->setParent(hWnd);
            p->msgList->showWindow(true);
            p->msgList->wrapList=false;
            p->msgList->colorInterleaving=true;

            p->editWnd=DoCreateEditControl(hWnd);
            p->calcEditHeight();

            p->msgList->bindODRList(p->contact->messageList);
            break;
        }

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

        {
            //p->contact->nUnread=0;
            RECT rc = {0, 0, 200, tabHeight};
            SetBkMode(hdc, TRANSPARENT);
            SetTextColor(hdc, p->contact->getColor());
            p->contact->draw(hdc, rc);

            int iconwidth= skin->getElementWidth();
            skin->drawElement(hdc, icons::ICON_CLOSE, p->width-2-iconwidth, 0);
            skin->drawElement(hdc, icons::ICON_TRASHCAN_INDEX, p->width-2-iconwidth*2, 0);

            /*SetBkMode(hdc, TRANSPARENT);
            LPCTSTR t=p->title.c_str();
            DrawText(hdc, t, -1, &rc, DT_CALCRECT | DT_LEFT | DT_TOP);
            DrawText(hdc, t, -1, &rc, DT_LEFT | DT_TOP);*/
        }

        EndPaint(hWnd, &ps);
        break;

    //case WM_KILLFOCUS:
    //    p->contact->nUnread=0;
    //    break;

    case WM_SIZE: 
        { 
            HDWP hdwp; 
            RECT rc; 

            int height=GET_Y_LPARAM(lParam);
            p->width=GET_X_LPARAM(lParam);

            int ySplit=height-p->editHeight;

            p->calcEditHeight();

            // Calculate the display rectangle, assuming the 
            // tab control is the size of the client area. 
            SetRect(&rc, 0, 0, 
                GET_X_LPARAM(lParam), ySplit ); 

            // Size the tab control to fit the client area. 
            hdwp = BeginDeferWindowPos(2);

            /*DeferWindowPos(hdwp, dropdownWnd, HWND_TOP, 0, 0, 
            GET_X_LPARAM(lParam), 20, 
            SWP_NOZORDER 
            ); */


            DeferWindowPos(hdwp, p->msgList->getHWnd(), HWND_TOP, 0, tabHeight, 
                GET_X_LPARAM(lParam), ySplit-tabHeight, 
                SWP_NOZORDER 
                );
            /*DeferWindowPos(hdwp, rosterWnd, HWND_TOP, 0, tabHeight, 
            GET_X_LPARAM(lParam), height-tabHeight, 
            SWP_NOZORDER 
            );*/

            DeferWindowPos(hdwp, p->editWnd, NULL, 0, ySplit+1, 
                GET_X_LPARAM(lParam), height-ySplit-1, 
                SWP_NOZORDER 
                ); 

            EndDeferWindowPos(hdwp); 

            break; 
        } 

    case WM_COMMAND: 
        {
            if (wParam==IDS_SEND) {
                p->sendJabberMessage();
            }
            if (wParam==IDC_COMPLETE) {
                p->mucNickComplete();
            }

            if (wParam==IDC_COMPOSING) {
                p->setComposingState(lParam!=0);
            }
            break;             
        }
        /*case WM_CTLCOLORSTATIC:
        case WM_CTLCOLORLISTBOX:
        case WM_CTLCOLOREDIT: 
        {
        //HGDIOBJ brush= GetStockObject(GRAY_BRUSH);
        //HGDIOBJ pen= GetStockObject(WHITE_PEN);
        SetBkColor(hdc, 0x808080);
        SetTextColor(hdc, 0xffffff);
        //SelectObject((HDC)wParam, brush);
        //SelectObject((HDC)wParam, pen);
        return (BOOL) GetStockObject(GRAY_BRUSH);
        break;
        }*/

    case WM_LBUTTONDOWN:
        SetFocus(hWnd);
        if ((GET_Y_LPARAM(lParam))>tabHeight) break;
        
        if (GET_X_LPARAM(lParam) > (p->width)-2-(skin->getElementWidth()) ) {
            PostMessage(GetParent(hWnd), WM_COMMAND, TabsCtrl::CLOSETAB, 0);
            break;
        }
        if (GET_X_LPARAM(lParam) > (p->width)-2-(skin->getElementWidth())*2) {
            int result=MessageBox(
                p->getHWnd(), 
                L"Are You sure want to clear this chat session?", 
                L"Clear chat", 
                MB_YESNO | MB_ICONWARNING);
            if (result==IDYES) {
                p->contact->messageList->clear();
                p->msgList->moveCursorEnd();
            }
            break;
        }
        break;

    case WM_DESTROY:
        //TODO: Destroy all child data associated eith this window

        return 0;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
示例#2
0
LRESULT CALLBACK ServiceDiscovery::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
    PAINTSTRUCT ps;
    HDC hdc;
    ServiceDiscovery *p=(ServiceDiscovery *) GetWindowLong(hWnd, GWL_USERDATA);

    switch (message) {
    case WM_CREATE:
        {
            p=(ServiceDiscovery *) (((CREATESTRUCT *)lParam)->lpCreateParams);
            SetWindowLong(hWnd, GWL_USERDATA, (LONG) p );

            //p->nodeList=VirtualListView::ref(new VirtualListView(hWnd, std::string("disco")));
            DiscoListView * dlv = new DiscoListView(hWnd, std::string("disco"));
            //dlv->serviceDiscovery=p->thisRef;

            p->nodeList=VirtualListView::ref(dlv);
            p->nodeList->setParent(hWnd);
            p->nodeList->showWindow(true);
            //p->nodeList->wrapList=false;
            //p->nodeList->colorInterleaving=true;

            RECT rect;
            p->editWnd=DoCreateComboControl(hWnd);
            GetWindowRect(p->editWnd, &rect);
            p->editHeight=rect.bottom-rect.top+2;
            mru::readMru(MRU_DISCO_JIDS, p->editWnd, NULL);

            //p->msgList->bindODRList(p->contact->messageList);
            break;
        }

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

        {
            //p->contact->nUnread=0;
            RECT rc = {0, 0, 200, tabHeight};
            SetBkMode(hdc, TRANSPARENT);
            //SetTextColor(hdc, p->contact->getColor());
            //p->contact->draw(hdc, rc);

            skin->drawElement(hdc, icons::ICON_CLOSE, p->width-2-skin->getElementWidth(), 0);
            skin->drawElement(hdc, icons::ICON_SEARCH_INDEX, p->width-4-skin->getElementWidth()*2, 0);

            

            /*SetBkMode(hdc, TRANSPARENT);
            LPCTSTR t=p->title.c_str();
            DrawText(hdc, t, -1, &rc, DT_CALCRECT | DT_LEFT | DT_TOP);
            DrawText(hdc, t, -1, &rc, DT_LEFT | DT_TOP);*/
        }

        EndPaint(hWnd, &ps);
        break;

    case WM_SIZE: 
        { 
            HDWP hdwp; 
            RECT rc; 

            int height=GET_Y_LPARAM(lParam);
            p->width=GET_X_LPARAM(lParam);

            // Calculate the display rectangle, assuming the 
            // tab control is the size of the client area. 
            SetRect(&rc, 0, 0, 
                GET_X_LPARAM(lParam), height ); 

            // Size the tab control to fit the client area. 
            hdwp = BeginDeferWindowPos(2);

            DeferWindowPos(hdwp, p->editWnd, NULL, 1, 1, 
                GET_X_LPARAM(lParam)-(tabHeight*2+2), p->editHeight, 
                SWP_NOZORDER 
                ); 


            DeferWindowPos(hdwp, p->nodeList->getHWnd(), HWND_TOP, 0, p->editHeight, 
                GET_X_LPARAM(lParam), height - p->editHeight, 
                SWP_NOZORDER 
                );

            EndDeferWindowPos(hdwp); 

            break; 
        } 

    case WM_COMMAND: 
        {
            switch (LOWORD(wParam)) {
            case IDOK:
                {
                    updateComboHistory(p->editWnd);
                    while (!p->nodes.empty()) p->nodes.pop();
                    p->nodeList->bindODRList(ODRListRef());
                    p->newNode.clear();
                    p->go();
                    break;
                }
            }
        }
        if (HIWORD(wParam)==CBN_DROPDOWN) {
            int nitems=SendMessage(p->editWnd, CB_GETCOUNT, 0, 0);
            if (nitems<=0) break;
            int h=SendMessage(p->editWnd, CB_GETITEMHEIGHT, 0, 0)*10;//+p->editHeight;
            RECT rc;
            GetWindowRect((HWND)lParam, &rc);
            int result=SetWindowPos((HWND)lParam, NULL, 0,0, rc.right-rc.left, h, SWP_NOZORDER | SWP_NOMOVE );
        }
        break;             

    case WM_LBUTTONDOWN:
        SetFocus(hWnd);
        if ((GET_Y_LPARAM(lParam)) > p->editHeight) break;
        if (GET_X_LPARAM(lParam) > p->width-2-skin->getElementWidth()) {
            mru::saveMru(MRU_DISCO_JIDS, p->editWnd);
            PostMessage(GetParent(hWnd), WM_COMMAND, TabsCtrl::CLOSETAB, 0);
            break;
        }
        if (GET_X_LPARAM(lParam) > p->width-2-2*skin->getElementWidth()) {
            SendMessage(hWnd, WM_COMMAND, IDOK, 0);
        }
        break;

    case WM_NOTIFY_BLOCKARRIVED:
        p->parseResult();
        return 0;

    case WM_DESTROY:
        //TODO: Destroy all child data associated eith this window

        return 0;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
示例#3
0
LRESULT CALLBACK HtmlView::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
    HtmlView *p=(HtmlView *) GetWindowLong(hWnd, GWL_USERDATA);

    switch (message) {
    case WM_CREATE:
        {
            p=(HtmlView *) (((CREATESTRUCT *)lParam)->lpCreateParams);
            SetWindowLong(hWnd, GWL_USERDATA, (LONG) p );


            RECT rc;

            GetClientRect (hWnd, &rc);

            p->htmlHWnd = CreateWindow (
                DISPLAYCLASS, 
                NULL, 
                WS_CHILD | WS_VISIBLE | /*WS_VSCROLL |*/ WS_CLIPSIBLINGS, 
                rc.left, rc.top,
                rc.right - rc.left, rc.bottom - rc.top, 
                hWnd, 
                0, //(HMENU)IDC_HTMLVIEW, 
                g_hInst, 
                NULL);

            SetFocus(p->htmlHWnd);

            HWND hwndHTML=p->htmlHWnd;
            bool   fFitToPage = TRUE;
            PostMessage(hwndHTML, DTM_ENABLESHRINK, 0, fFitToPage);

            SendMessage(hwndHTML, WM_SETTEXT, 0, (LPARAM)"");
            SendMessage(hwndHTML, DTM_ADDTEXT, FALSE, 
                (LPARAM)"<HTML><TITLE>Test</TITLE><BODY><P>Loading...<BR></BODY></HTML>");
            SendMessage(hwndHTML, DTM_ENDOFSOURCE, 0, (LPARAM)NULL);


            /*SendMessage(hwndHTML, WM_SETTEXT, 0, (LPARAM)"");
            SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("<HTML><TITLE>Test</TITLE>"));
            SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("<BODY><P>"));
            SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("<h1>Heading</h1>Normal Text<BR>"));
            SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("<A HREF=\"www.voscorp.com\"><IMG SRC=\"\\Pic.gif\"></A>"));
            SendMessage(hwndHTML, DTM_ADDTEXTW, FALSE, (LPARAM)TEXT("</BODY></HTML>"));
            SendMessage(hwndHTML, DTM_ENDOFSOURCE, 0, (LPARAM)NULL);*/

            break;

        }

    case WM_PAINT:

        {
            PAINTSTRUCT ps;
            HDC hdc;
            hdc = BeginPaint(hWnd, &ps);

            RECT rc = {0, 0, p->width, p->wt->getHeight()};

            SetBkMode(hdc, TRANSPARENT);
            SetTextColor(hdc, p->wt->getColor());
            p->wt->draw(hdc, rc,0);

            skin->drawElement(hdc, icons::ICON_CLOSE, p->width-2-skin->getElementWidth(), 0);


            EndPaint(hWnd, &ps);
            break;
        }

    case WM_SIZE: 
        { 
            //HDWP hdwp; 

            int height=GET_Y_LPARAM(lParam);
            int width=GET_X_LPARAM(lParam); p->width=width;

            int xHeight=tabHeight;/*p->wt->getHeight();*/
            // Calculate the display rectangle, assuming the 
            // tab control is the size of the client area. 
            SetRect(&(p->clientRect), 0, 0, width, height ); 

            if(IsWindow(p->htmlHWnd))
                SetWindowPos(p->htmlHWnd, 0, 0, xHeight, width, height-xHeight, SWP_NOZORDER );
            /*hdwp = BeginDeferWindowPos(1);

            DeferWindowPos(hdwp, p->listScrollHWND, HWND_TOP, width-SCROLLWIDTH, tabHeight, 
            SCROLLWIDTH, height-tabHeight, 
            SWP_NOZORDER 
            );
            EndDeferWindowPos(hdwp); */

            break; 
        } 

    case WM_NOTIFY:
        //if (wParam!=IDC_HTMLVIEW) break;
        {
            NM_HTMLVIEW* pnm = (NM_HTMLVIEW*)lParam;

            switch(pnm->hdr.code) 
            {
            case NM_INLINE_IMAGE:
                {
                    DWORD cookie=pnm->dwCookie;
                    HBITMAP bmp=p->getImage(pnm->szTarget, pnm->dwCookie);
                    p->setImage(bmp, cookie);
                    return TRUE;
                } // end case NM_INLINE_IMAGE:
            case NM_HOTSPOT:
                {
                    if (pnm->szTarget!=NULL)
                        p->onHotSpot((LPCSTR)pnm->szTarget, (LPCSTR)pnm->szData);
                    return TRUE;
                }
            } // end switch(pnm->hdr.code)
        } // End case IDC_HTMLVIEW:
        break;

    case WM_LBUTTONDOWN:
        SetFocus(hWnd);
        if ((GET_Y_LPARAM(lParam))>tabHeight) break;
        if (GET_X_LPARAM(lParam) > p->width-2-skin->getElementWidth()) {
            PostMessage(GetParent(hWnd), WM_COMMAND, TabsCtrl::CLOSETAB, 0);
        }
        break;

    case WM_HTML_UPDATE:
        {
            p->onWmUserUpdate();
            break;
        }
    case WM_DESTROY:
        //TODO: Destroy all child data associated eith this window
        //WARNING! do not place virtual member calls here - object is already destructed 
        return 0;

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