📄 wdecust.c
字号:
UINT i;
if ( !list ) {
return;
}
*list = NULL;
if ( class ) {
for ( llist = WdeCustomLibList; llist; llist = ListNext(llist) ) {
if ( lib = (WdeCustLib *) ListElement(llist) ) {
for ( i=0; i<lib->num_classes; ++i ) {
if ( !strcmpi ( class, lib->lpcci[i].szClass ) ) {
ListAddElt( list, (void *) &(lib->lpcci[i]) );
}
}
}
}
}
return;
}
Bool WdeFindLibIndexFromInfo ( LPCCINFO lpcci, WdeCustLib **lib,
UINT *index )
{
LIST *llist;
WdeCustLib *l;
UINT i;
if ( !lib || !index ) {
return ( FALSE );
}
*lib = NULL;
*index = 0;
if ( lpcci ) {
for ( llist = WdeCustomLibList; llist; llist = ListNext(llist) ) {
if ( l = (WdeCustLib *) ListElement(llist) ) {
for ( i=0; i<l->num_classes; ++i ) {
if ( &(l->lpcci[i]) == lpcci ) {
*lib = l;
*index = i;
return ( TRUE );
}
}
}
}
}
return ( FALSE );
}
void WdeFreeSelectWinCBox ( HWND win )
{
HWND cbox;
LRESULT count;
WdeCurrCustControl *current;
cbox = GetDlgItem ( win, IDB_CUST_DESC );
count = SendMessage ( cbox, CB_GETCOUNT, 0, 0 );
if( count > 0 ) {
do {
current = (WdeCurrCustControl *)
SendMessage ( cbox, CB_GETITEMDATA, (WPARAM)count, 0 );
if( current ) {
WdeMemFree( current );
SendMessage( cbox, CB_SETITEMDATA, count, (LPARAM) NULL );
}
count--;
} while( count != 0 );
}
return;
}
Bool WdeSetSelectWinCBox ( HWND cbox, WdeCustLib *lib )
{
WdeCurrCustControl *current;
UINT i;
LRESULT index;
for ( i = 0; i < lib->num_classes; ++i ) {
current = (WdeCurrCustControl *)
WdeMemAlloc ( sizeof(WdeCurrCustControl) );
if ( !current ) {
WdeWriteTrail("WdeSetSelectWinCBox: alloc failed!");
return ( FALSE );
}
current->lib = lib;
current->index = i;
index = SendMessage ( cbox, CB_ADDSTRING, 0, (LPARAM) (LPCSTR )
lib->lpcci[i].szDesc );
if ( ( index == CB_ERR ) || ( index == CB_ERRSPACE ) ) {
WdeWriteTrail("WdeSetSelectWinCBox: CB_ADDSTRING failed!");
WdeMemFree ( current );
return ( FALSE );
}
index = SendMessage ( cbox, CB_SETITEMDATA, index,
(LPARAM) (DWORD) current );
if ( index == CB_ERR ) {
WdeWriteTrail("WdeSetSelectWinCBox: CB_SETITEMDATA failed!");
WdeMemFree ( current );
return ( FALSE );
}
}
return ( TRUE );
}
Bool WdeSetSelectWin ( HWND win )
{
HWND cbox;
LIST *llist;
WdeCustLib *lib;
cbox = GetDlgItem ( win, IDB_CUST_DESC );
if ( WdeCustomLibList ) {
for ( llist = WdeCustomLibList; llist; llist = ListNext(llist) ) {
lib = (WdeCustLib *) ListElement(llist);
if ( !WdeSetSelectWinCBox ( cbox, lib ) ) {
return ( FALSE );
}
}
}
return ( TRUE );
}
Bool WdeSetCurrentControl ( HWND win, int which )
{
LRESULT index;
WdeCurrCustControl *current;
index = SendDlgItemMessage ( win, IDB_CUST_DESC, CB_GETCOUNT, 0, 0 );
if ( !index || (index == CB_ERR) ) {
return ( TRUE );
}
index = SendDlgItemMessage ( win, IDB_CUST_DESC, CB_GETCURSEL, 0, 0 );
current = (WdeCurrCustControl *)
SendDlgItemMessage ( win, IDB_CUST_DESC, CB_GETITEMDATA,
(WPARAM)index, 0 );
if ( current == NULL ) {
WdeWriteTrail("WdeSetCurrentControl: CB_GETITEMDATA failed!");
return ( FALSE );
}
WdeCurrControl[which].lib = current->lib;
WdeCurrControl[which].index = current->index;
return ( TRUE );
}
void WdeMapCustomSize( UINT *w, UINT *h, WdeResizeRatio *r )
{
RECT trect;
DialogSizeInfo dsize;
dsize.x = 0;
dsize.y = 0;
dsize.width = *w;
dsize.height = *h;
WdeDialogToScreen( NULL, r, &dsize, &trect );
*w = trect.right;
*h = trect.bottom;
}
Bool WdePreviewSelected ( HWND win )
{
WdeCurrCustControl *current;
LRESULT index;
char *class;
char *caption;
HWND pwin;
HWND parea;
RECT psize;
RECT trect;
DWORD pstyle;
DWORD pestyle;
POINT p;
UINT pwidth;
UINT pheight;
WdeResizeRatio resizer;
index = SendDlgItemMessage ( win, IDB_CUST_DESC, CB_GETCOUNT, 0, 0 );
if ( !index || (index == CB_ERR) ) {
return ( TRUE );
}
parea = GetDlgItem ( win, IDB_CUST_PREVIEW );
pwin = GetDlgItem ( win, WDE_PREVIEW_ID );
if ( pwin != NULL ) {
DestroyWindow ( pwin );
}
GetClientRect ( parea, &psize );
InflateRect ( &psize, -WDE_PREVIEW_PAD, -WDE_PREVIEW_PAD );
index = SendDlgItemMessage ( win, IDB_CUST_DESC, CB_GETCURSEL, 0, 0 );
current = (WdeCurrCustControl *)
SendDlgItemMessage ( win, IDB_CUST_DESC, CB_GETITEMDATA,
(WPARAM)index, 0 );
if ( current == NULL ) {
WdeWriteTrail("WdePreviewSelected: CB_GETITEMDATA failed!");
return ( FALSE );
}
if ( current->lib->lpcci[current->index].flOptions & CCF_NOTEXT ) {
caption = NULL;
} else {
caption = current->lib->lpcci[current->index].szTextDefault;
}
class = current->lib->lpcci[current->index].szClass;
pstyle = current->lib->lpcci[current->index].flStyleDefault;
pestyle = current->lib->lpcci[current->index].flExtStyleDefault;
pwidth = current->lib->lpcci[current->index].cxDefault;
pheight = current->lib->lpcci[current->index].cyDefault;
WdeGetResizerFromFont ( &resizer, "System", 10 );
WdeMapCustomSize( &pwidth, &pheight, &resizer );
if ( pwidth > (psize.right - psize.left) ) {
pwidth = psize.right - psize.left;
}
if ( pheight > (psize.bottom - psize.top) ) {
pheight = psize.bottom - psize.top;
}
p.x = 0;
p.y = 0;
SendDlgItemMessage ( win, IDB_CUST_CLASSNAME, WM_SETTEXT,
0, (LPARAM) (LPCSTR ) class );
pstyle &= ( 0xffffffff ^ ( WS_POPUP | WS_VISIBLE | WS_TABSTOP ) );
pstyle |= WS_CHILD;
pwin = CreateWindowEx ( pestyle, class, caption,
pstyle, p.x, p.y, pwidth, pheight, win,
(HMENU) WDE_PREVIEW_ID,
WdeGetAppInstance(), NULL);
if ( pwin == NULL ) {
WdeWriteTrail("WdePreviewSelected: CreateWindow failed!");
return ( FALSE );
}
GetClientRect ( pwin, &trect );
pwidth = trect.right;
pheight = trect.bottom;
p.x = ( (psize.right - psize.left) - pwidth ) / 2 + WDE_PREVIEW_PAD;
p.y = ( (psize.bottom - psize.top) - pheight ) / 2 + WDE_PREVIEW_PAD;
MapWindowPoints ( parea, win, &p, 1 );
SetWindowPos ( pwin, (HWND) NULL, p.x, p.y, 0, 0,
SWP_NOZORDER | SWP_NOSIZE );
ShowWindow ( pwin, SW_SHOW );
return ( TRUE );
}
BOOL WINEXPORT WdeSelectCustProc ( HWND hDlg, UINT message,
WPARAM wParam, volatile LPARAM lParam )
{
static int which = 0;
BOOL ret;
ret = FALSE;
switch (message) {
case WM_SETFONT:
WdeSelectFont = (HFONT) wParam;
break;
case WM_INITDIALOG:
which = *( (int *) lParam );
if ( !WdeSetSelectWin ( hDlg ) ) {
WdeFreeSelectWinCBox ( hDlg );
EndDialog(hDlg, FALSE);
}
SendDlgItemMessage ( hDlg, IDB_CUST_DESC, CB_SETCURSEL, 0, 0 );
WdePreviewSelected ( hDlg );
break;
case WM_COMMAND:
switch ( LOWORD(wParam) ) {
case IDB_HELP:
WinHelp( WdeGetMainWindowHandle(), "resdlg.hlp",
HELP_CONTENTS, 0 );
break;
case IDOK:
WdeSetCurrentControl ( hDlg, which );
WdeFreeSelectWinCBox ( hDlg );
EndDialog(hDlg, TRUE);
ret = TRUE;
break;
case IDCANCEL:
WdeFreeSelectWinCBox ( hDlg );
EndDialog(hDlg, FALSE);
ret = TRUE;
break;
case IDB_CUST_DESC:
switch ( GET_WM_COMMAND_CMD(wParam,lParam) ) {
case CBN_CLOSEUP:
WdePreviewSelected ( hDlg );
break;
}
}
}
return ( ret );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -