controlFunctions.h
#ifndef CONTROLFUNC_H
#define CONTROLFUNC_H
#include <windows.h>
bool setComboBox_width(HWND dialog, int CID, int width, bool status);
#endif // CONTROLFUNC_H
controlFunctions.cpp
#include "controlFunctions.h"
bool setComboBox_width(HWND dialog, int CID, int width, bool status){
HWND control = GetDlgItem(dialog, CID);
SendMessage(control, CB_SETDROPPEDWIDTH, width, 0);
return !status;
}
editunits2.h
#ifndef EDITUNITS2_H
#define EDITUNITS2_H
// included files here...
#include "controlFunctions.h"
struct UWidthsbase_t
{
int collapse;
int expand;
};
struct UWidths_t
{
UWidthsbase_t group;
UWidthsbase_t terrain;
UWidthsbase_t uConst;
};
UWidths_t UWidths = { {31, 85}, {31, 185}, {31, 200}};
UWidthsbase_t * pUWidthsClass = &(UWidths).group;
UWidthsbase_t * pUWidthsTerrain = &(UWidths).terrain;
UWidthsbase_t * pUWidthsConst = &(UWidths).uConst;
#endif // EDITUNITS2_H
INT_PTR CALLBACK Units2DlgProc(HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
ret = Units_HandleInit2(dialog);
break;
case WM_COMMAND:
ret = 0;
Units_HandleCommand2(dialog, HIWORD(wParam), LOWORD(wParam), (HWND)lParam);
break;
}
}
void Units_HandleCommand2(HWND dialog, WORD code, WORD id, HWND control)
{
switch (code)
{
case BN_CLICKED:
break;
case CBN_SELCHANGE:
break;
case EN_SETFOCUS:
break;
case EN_KILLFOCUS:
break;
case CBN_DROPDOWN:
if ( id >= IDC_UCLASS1 || id <= IDC_UCLASS16)
setComboBox_width(dialog, id, (*pUWidthsClass).expand, true);
else if ( id >= IDC_TERRAIN1 || id <= IDC_TERRAIN16 )
setComboBox_width(dialog, id, (*pUWidthsTerrain).expand, true);
else if ( id >= IDC_UCONST1 || id <= IDC_UCONST16 )
setComboBox_width(dialog, id, (*pUWidthsConst).expand, true);
break;
case CBN_CLOSEUP:
if ( id >= IDC_UCLASS1 || id <= IDC_UCLASS16)
setComboBox_width(dialog, id, (*pUWidthsClass).collapse, false);
else if ( id >= IDC_TERRAIN1 || id <= IDC_TERRAIN16 )
setComboBox_width(dialog, id, (*pUWidthsTerrain).collapse, false);
else if ( id >= IDC_UCONST1 || id <= IDC_UCONST16 )
setComboBox_width(dialog, id, (*pUWidthsConst).collapse, false);
break;
}
}
Mám hotovo, ale zatím nemohu přijít proč se mi všude nastavuje stejná šířka když rozbaluju.