BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { int i, size; static HFONT font; switch (uMsg) { case WM_INITDIALOG: for (i = langs_num - 1; i >= 0; i--) { SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)langs[i].name); } SetDlgItemText(hwndDlg, IDC_TEXT, g_wndtext); SetWindowText(hwndDlg, g_wndtitle); SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0); for (i = 0; i < langs_num; i++) { if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) { SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, langs_num-i-1, 0); break; } } if (dofont && !popstring(temp)) { size = myatoi(temp); if (!popstring(temp)) { LOGFONT f = {0,}; if (lstrcmp(temp, "MS Shell Dlg")) { f.lfHeight = -MulDiv(size, GetDeviceCaps(GetDC(hwndDlg), LOGPIXELSY), 72); lstrcpy(f.lfFaceName, temp); font = CreateFontIndirect(&f); SendMessage(hwndDlg, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDOK, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDCANCEL, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_TEXT, WM_SETFONT, (WPARAM)font, 1); } } } ShowWindow(hwndDlg, SW_SHOW); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: pushstring(langs[langs_num-SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0)-1].id); EndDialog(hwndDlg, 0); break; case IDCANCEL: pushstring("cancel"); EndDialog(hwndDlg, 1); break; } break; case WM_CLOSE: if (font) DeleteObject(font); pushstring("cancel"); EndDialog(hwndDlg, 1); break; default: return 0; } return 1; }
void __declspec(dllexport) myFunction(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { g_hwndParent=hwndParent; EXDLL_INIT(); // note if you want parameters from the stack, pop them off in order. // i.e. if you are called via exdll::myFunction file.dat poop.dat // calling popstring() the first time would give you file.dat, // and the second time would give you poop.dat. // you should empty the stack of your parameters, and ONLY your // parameters. // do your stuff here { char buf[1024]; wsprintf(buf,"$0=%s\n",getuservariable(INST_0)); MessageBox(g_hwndParent,buf,0,MB_OK); } }
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { INT_PTR i; int size; TCHAR *selected_language = NULL; static HFONT font; switch (uMsg) { case WM_INITDIALOG: // add languages for (i = visible_langs_num - 1; i >= 0; i--) { int cbi; cbi = (int)SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name); SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, cbi, (LPARAM) langs[i].id); // remember selected language if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) { selected_language = langs[i].name; } } // select the current language if (selected_language) SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) selected_language); else SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, 0, 0); // set texts SetDlgItemText(hwndDlg, IDC_TEXT, g_wndtext); SetWindowText(hwndDlg, g_wndtitle); SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0); // set font if (dofont && !popstring(temp)) { size = myatou(temp); if (!popstring(temp)) { LOGFONT f = {0,}; if (lstrcmp(temp, _T("MS Shell Dlg"))) { f.lfHeight = -MulDiv(size, GetDeviceCaps(GetDC(hwndDlg), LOGPIXELSY), 72); lstrcpy(f.lfFaceName, temp); font = CreateFontIndirect(&f); SendMessage(hwndDlg, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDOK, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDCANCEL, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_TEXT, WM_SETFONT, (WPARAM)font, 1); } } } // show window ShowWindow(hwndDlg, SW_SHOW); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: // push result on the stack i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0); i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0); if (i != CB_ERR && i) { pushstring((TCHAR *) i); } else { // ?! pushstring(_T("cancel")); } // end dialog EndDialog(hwndDlg, 0); break; case IDCANCEL: // push "cancel" on the stack pushstring(_T("cancel")); // end dialog EndDialog(hwndDlg, 0); break; } break; case WM_DESTROY: // clean up if (font) DeleteObject(font); break; default: return FALSE; // message not processed } return TRUE; // message processed }
slide_show(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { EXDLL_INIT(); slide_abort(); // argument default values iHAlign = HALIGN_CENTER; iVAlign = VALIGN_CENTER; iFit = FIT_BOTH; g_hWnd = NULL; captionColor = RGB(255,255,255); int duration = 1000; // transition duration in ms (default = 1s) TCHAR caption[MAX_PATH]; caption[0] = '\0'; // parse arguments TCHAR arg[MAX_PATH]; LPTSTR argValue; while(!popstring(arg, sizeof arg) && *arg == '/' && (argValue = StrChr(arg, '=')) != NULL) { *argValue++ = '\0'; // replace '=' by '\0' if(lstrcmpi(arg, TEXT("/hwnd")) == 0) StrToIntEx(argValue, STIF_SUPPORT_HEX, (int*) &g_hWnd); else if(lstrcmpi(arg, TEXT("/fit")) == 0) { if(lstrcmpi(argValue, TEXT("height")) == 0) iFit = FIT_HEIGHT; else if(lstrcmpi(argValue, TEXT("width")) == 0) iFit = FIT_WIDTH; else if(lstrcmpi(argValue, TEXT("stretch")) == 0) iFit = FIT_STRETCH; } else if(lstrcmpi(arg, TEXT("/halign")) == 0) { if(lstrcmpi(argValue, TEXT("left")) == 0) iHAlign = HALIGN_LEFT; else if(lstrcmpi(argValue, TEXT("right")) == 0) iHAlign = HALIGN_RIGHT; } else if(lstrcmpi(arg, TEXT("/valign")) == 0) { if(lstrcmpi(argValue, TEXT("top")) == 0) iVAlign = VALIGN_TOP; else if(lstrcmpi(argValue, TEXT("bottom")) == 0) iVAlign = VALIGN_BOTTOM; } else if(lstrcmpi(arg, TEXT("/duration")) == 0) StrToIntEx(argValue, STIF_SUPPORT_HEX, &duration); else if(lstrcmpi(arg, TEXT("/caption")) == 0) lstrcpy(caption, argValue); else if(lstrcmpi(arg, TEXT("/ccolor")) == 0) StrToIntEx(argValue, STIF_SUPPORT_HEX, (int*) &captionColor); else if(lstrcmpi(arg, TEXT("/auto")) == 0) { lstrcpy(g_autoPath, argValue); PathRemoveFileSpec(g_autoPath); HGLOBAL hMem = GlobalAlloc(GMEM_FIXED, 32767*sizeof(TCHAR)); DWORD count = GetPrivateProfileSection(getuservariable(INST_LANG), LPTSTR(hMem), 32767, argValue); if (count == 0) { count = GetPrivateProfileSection(TEXT("1033"), LPTSTR(hMem), 32767, argValue); if (count == 0) count = GetPrivateProfileSection(TEXT("0"), LPTSTR(hMem), 32767, argValue); } if (count) { g_autoBuffer = LPTSTR(GlobalReAlloc(hMem, (count+1)*sizeof(TCHAR), 0)); g_autoNext = g_autoBuffer; } else GlobalFree(hMem); } } // if target window not defined we'll search for default (the details listview) if (g_hWnd == NULL) { g_hWnd = FindWindowEx(hwndParent, NULL, TEXT("#32770"), NULL); if (g_hWnd == NULL) return; hwndParent = FindWindowEx(hwndParent, g_hWnd, TEXT("#32770"), NULL); if (hwndParent != NULL && !IsWindowVisible(hwndParent)) g_hWnd = hwndParent; if (g_hWnd == NULL) return; HWND hWnd = GetDlgItem(g_hWnd, 1016); GetWindowRect(hWnd, &rDest); ScreenToClient(g_hWnd, (LPPOINT) &rDest.left); ScreenToClient(g_hWnd, (LPPOINT) &rDest.right); } else GetClientRect(g_hWnd, &rDest); // load new image if (arg[0] == '\0') return; // stop here if no filename if (g_autoNext != NULL) slide_NextAuto(); else slide_NewImage(arg, caption, duration); }
void NSISCALL GetUserVariableA(const int varnum, char* ansiStr) { wchar_t* wideStr = getuservariable(varnum); WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL); }
void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr) { lstrcpyW(wideStr, getuservariable(varnum)); }
void NSISCALL GetUserVariableA(const int varnum, char* ansiStr) { lstrcpyA(ansiStr, getuservariable(varnum)); }
void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr) { char* ansiStr = getuservariable(varnum); MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize); }