Example #1
0
void Twindow::resizeDialog(HWND hwnd)
{
    if(!hwnd || resized) {
        return;
    }

    int scale;

    if (tr) {
        scale=Ttranslate::lastHorizontalScale=tr->font.horizontalScale;
    } else {
        scale=Ttranslate::lastHorizontalScale;
    }

    if (scale == 100) {
        return;
    }

    resizeDialog(hwnd,false,scale);

    THWNDs wnds;

    getChildWindows(hwnd,wnds);

    for (THWNDs::const_iterator wnd=wnds.begin(); wnd!=wnds.end(); wnd++)
        if (*wnd) {
            resizeDialog(*wnd,true,scale);
        }

    resized=true;
}
Example #2
0
void Twindow::setHWND(HWND Im_hwnd,int IdialogId)
{
    m_hwnd=Im_hwnd;
    if (IdialogId) {
        dialogId=IdialogId;
    }
    THWNDs wnds;
    getChildWindows(m_hwnd,wnds);
    for (THWNDs::const_iterator wnd=wnds.begin(); wnd!=wnds.end(); wnd++) {
        Twidget *dlgitem=createDlgItem(getId(*wnd),*wnd);
        if (tr->translateMode && dialogId!=IDD_PROPSEDIT) {
            char_t className[256];
            GetClassName(*wnd,className,256);
            if (stricmp(className,_l("STATIC"))==0 || stricmp(className,_l("BUTTON"))==0 || stricmp(className,_l("ComboBox"))==0 || stricmp(className,_l("syslistview32"))==0) {
                if (stricmp(className,_l("STATIC"))==0) {
                    SetWindowLong(*wnd,GWL_STYLE,GetWindowLong(*wnd,GWL_STYLE)|SS_NOTIFY);
                } else if (stricmp(className,_l("BUTTON"))==0) {
                    SetWindowLong(*wnd,GWL_STYLE,GetWindowLong(*wnd,GWL_STYLE)|BS_NOTIFY);
                    if ((GetWindowLong(*wnd,GWL_STYLE)&BS_GROUPBOX)==BS_GROUPBOX) {
                        char_t windowtext[256];
                        GetWindowText(*wnd,windowtext,256);
                        if (windowtext[0]!='\0') {
                            SendMessage(*wnd,BM_SETSTYLE,BS_PUSHBUTTON,1);
                            RECT r;
                            GetWindowRect(*wnd,&r);
                            SetWindowPos(*wnd,NULL,0,0,r.right-r.left,15,SWP_NOMOVE|SWP_NOZORDER);
                        }
                    }
                }
                EnableWindow(*wnd,TRUE);
                dlgitem->allowOwnProc(); //setDlgItemProc(*wnd,translateProc);
            }
        }
    }
    Twidget *dlgitem=createDlgItem(0,m_hwnd);
    //SetWindowLong(m_hwnd,GWL_USERDATA,LONG(createDlgItem()));
    if (tr->translateMode) {
        dlgitem->allowOwnProc();    // setDlgItemProc(m_hwnd,translateProc);
    }
}
Example #3
0
void TpresetAutoloadDlgBase::TitemsWindow::showItems(void)
{
    THWNDs hwnds;
    getChildWindows(m_hwnd, hwnds);
    for (THWNDs::const_iterator h = hwnds.begin(); h != hwnds.end(); h++) {
        DestroyWindow(*h);
    }
    int y = 0;
    HFONT fnt = (HFONT)SendMessage(m_hwnd, WM_GETFONT, 0, 0);
    CRect pr;
    GetWindowRect(m_hwnd, &pr);
    int prdlgdx = 170; //TODO: compute
    int id = 0;
    int sbrWidth = GetSystemMetrics(SM_CXVSCROLL) + 4;
    for (Titems::const_iterator i = items.begin(); i != items.end(); i++, id++) {
        CRect r(CPoint(0, y), CSize(prdlgdx, 10));
        MapDialogRect(m_hwnd, &r);
        HWND hchb = CreateWindow(_l("BUTTON"), _(-IDD_PRESET_AUTOLOAD_ITEMS, i->name), WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | WS_TABSTOP, r.left, r.top, r.Width() - sbrWidth, r.Height(), m_hwnd, HMENU(1000 + 10 * id + 1), hi, 0);
        SendMessage(hchb, WM_SETFONT, WPARAM(fnt), TRUE);
        setCheck(1000 + 10 * id + 1, i->is);
        y += 11;
        if (i->isVal) {
            static const int dxbt1 = 10;
            int dxbt = (i->isList ? dxbt1 : 0) + (i->isHelp ? dxbt1 : 0);
            r = CRect(CPoint(0, y), CSize(prdlgdx - dxbt, 12));
            MapDialogRect(m_hwnd, &r);
            HWND hed = CreateWindowEx(WS_EX_CLIENTEDGE, _l("EDIT"), NULL, WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, r.left, r.top, r.Width() - sbrWidth, r.Height(), m_hwnd, HMENU(1000 + 10 * id + 2), hi, 0);
            SendMessage(hed, WM_SETFONT, WPARAM(fnt), TRUE);
            SendMessage(hed, EM_SETLIMITTEXT, 255, 0);
            setWindowText(hed, i->val);
            if (i->hint && i->hint[0]) {
                addHint(1000 + 10 * id + 2, i->hint);
            }
            int btx = prdlgdx - dxbt;
            if (i->isList) {
                r = CRect(CPoint(btx, y), CSize(10, 12));
                MapDialogRect(m_hwnd, &r);
                btx += dxbt1;
                HWND hbt = CreateWindow(_l("BUTTON"), _l("6"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP, r.left - sbrWidth, r.top, r.Width(), r.Height(), m_hwnd, HMENU(1000 + 10 * id + 3), hi, 0);
                SendMessage(hbt, WM_SETFONT, WPARAM(arrowsFont), TRUE);
            }
            if (i->isHelp) {
                r = CRect(CPoint(btx, y), CSize(10, 12));
                MapDialogRect(m_hwnd, &r);
                HWND hbt = CreateWindow(_l("BUTTON"), _l("?"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | WS_TABSTOP, r.left - sbrWidth, r.top, r.Width(), r.Height(), m_hwnd, HMENU(1000 + 10 * id + 4), hi, 0);
                SendMessage(hbt, WM_SETFONT, WPARAM(fnt), TRUE);
            }
            y += 14;
        }
    }
    SCROLLINFO si;
    si.cbSize = sizeof(si);
    si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
    si.nMin = 0;
    CRect r(0, 0, 0, y);
    MapDialogRect(m_hwnd, &r);
    si.nMax = r.Height();
    si.nPage = pr.Height();
    si.nPos = 0;
    SetScrollInfo(m_hwnd, SB_VERT, &si, TRUE);
}
Example #4
0
INT_PTR Twindow::msgProc(UINT uMsg,WPARAM wParam,LPARAM lParam)
{
    switch (uMsg) {
        case WM_INITDIALOG:
            resizeDialog();
            init();
            //subClass();
            break;
        case WM_DESTROY: {
            THWNDs wnds;
            getChildWindows(m_hwnd,wnds);
            for (THWNDs::const_iterator wnd=wnds.begin(); wnd!=wnds.end(); wnd++) {
                ::Twidget *item=Twidget::getDlgItem(*wnd);
                if (item) {
                    item->restore();
                    delete item;
                }
            }
            ::Twidget *item=Twidget::getDlgItem(m_hwnd);
            if (item) {
                item->restore();
                delete item;
            }
            if (red) {
                DeleteObject(red);
            }
            red=NULL;
            break;
        }
        case WM_HSCROLL:
            if (onTrack(bindsHtrack,lParam)) {
                return TRUE;
            }
            break;
        case WM_VSCROLL:
            if (onTrack(bindsVtrack,lParam)) {
                return TRUE;
            }
            break;
        case WM_COMMAND: {
            if (bindsCheckbox)
                for (int i=0; bindsCheckbox[i].idc; i++)
                    if (bindsCheckbox[i].idc==LOWORD(wParam)) {
                        if (bindsCheckbox[i].idff<0) {
                            cfgSet(-bindsCheckbox[i].idff,!getCheck(LOWORD(wParam)));
                        } else {
                            cfgSet(bindsCheckbox[i].idff,getCheck(LOWORD(wParam)));
                        }
                        if (bindsCheckbox[i].onClick) {
                            (this->*bindsCheckbox[i].onClick)();
                        }
                        return TRUE;
                    }
            if (bindsRadiobutton)
                for (int i=0; bindsRadiobutton[i].idc; i++)
                    if (bindsRadiobutton[i].idc==LOWORD(wParam) && getCheck(LOWORD(bindsRadiobutton[i].idc))) {
                        cfgSet(bindsRadiobutton[i].idff,bindsRadiobutton[i].val);
                        if (bindsRadiobutton[i].onClick) {
                            (this->*bindsRadiobutton[i].onClick)();
                        }
                        return TRUE;
                    }
            if (bindsButton)
                if (HIWORD(wParam)==BN_CLICKED) // works also for static
                    for (int i=0; bindsButton[i].idc; i++)
                        if (bindsButton[i].idc==LOWORD(wParam) && bindsButton[i].onClick) {
                            (this->*bindsButton[i].onClick)();
                            return TRUE;
                        }
            if (HIWORD(wParam)==EN_CHANGE && !isSetWindowText) {
                if (LOWORD(wParam)==IDC_ED_HELP && tr->translateMode) {
                    onEditChange();
                }
                if (bindsEditInt)
                    for (int i=0; bindsEditInt[i].idc; i++)
                        if (bindsEditInt[i].idc==LOWORD(wParam)) {
                            HWND hed=GetDlgItem(m_hwnd,bindsEditInt[i].idc);
                            if (hed!=GetFocus()) {
                                return FALSE;
                            }
                            repaint(hed);
                            eval(hed,bindsEditInt[i].min,bindsEditInt[i].max,bindsEditInt[i].idff);
                            if (bindsEditInt[i].onClick) {
                                (this->*bindsEditInt[i].onClick)();
                            }
                            return TRUE;
                        }
                if (bindsEditReal)
                    for (int i=0; bindsEditReal[i].idc; i++)
                        if (bindsEditReal[i].idc==LOWORD(wParam)) {
                            HWND hed=GetDlgItem(m_hwnd,bindsEditReal[i].idc);
                            if (hed!=GetFocus()) {
                                return FALSE;
                            }
                            repaint(hed);
                            eval(hed,bindsEditReal[i].min,bindsEditReal[i].max,bindsEditReal[i].idff,bindsEditReal[i].mult);
                            if (bindsEditReal[i].onClick) {
                                (this->*bindsEditReal[i].onClick)();
                            }
                            return TRUE;
                        }
            } else if (HIWORD(wParam)==CBN_SELCHANGE) {
                if (bindsCombobox)
                    for (int i=0; bindsCombobox[i].idc; i++)
                        if (bindsCombobox[i].idc==LOWORD(wParam)) {
                            switch (bindsCombobox[i].mode) {
                                case BINDCBX_DATA:
                                    cfgSet(bindsCombobox[i].idff,(int)cbxGetCurItemData(bindsCombobox[i].idc));
                                    break;
                                case BINDCBX_SEL:
                                    cfgSet(bindsCombobox[i].idff,cbxGetCurSel(bindsCombobox[i].idc));
                                    break;
                                case BINDCBX_TEXT:
                                    cfgSet(bindsCombobox[i].idff,cbxGetCurText(bindsCombobox[i].idc));
                                    break;
                                case BINDCBX_DATATEXT:
                                    cfgSet(bindsCombobox[i].idff,(const char_t*)cbxGetCurItemData(bindsCombobox[i].idc));
                                    break;
                            }
                            if (bindsCombobox[i].onClick) {
                                (this->*bindsCombobox[i].onClick)();
                            }
                            return TRUE;
                        }
            }
            break;
        }
        case WM_CTLCOLOREDIT:
            if (bindsEditInt)
                if (onCtlColorEdit(bindsEditInt,lParam,wParam)) {
                    return INT_PTR(getRed());
                }
            if (bindsEditReal)
                if (onCtlColorEdit(bindsEditReal,lParam,wParam)) {
                    return INT_PTR(getRed());
                }
            break;
    }
    return defMsgProc(uMsg,wParam,lParam);
}