void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { char *className; char *text; HWND hwItem; int x, y, width, height; DWORD style, exStyle; size_t id; // get info from stack className = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, g_stringsize * 2); text = &className[g_stringsize]; if (!className) { pushstring("error"); return; } if (popstringn(className, 0)) { pushstring("error"); HeapFree(GetProcessHeap(), 0, className); return; } style = (DWORD) popint_or(); exStyle = (DWORD) popint_or(); PopPlacement(&x, &y, &width, &height); if (popstringn(text, 0)) { pushstring("error"); HeapFree(GetProcessHeap(), 0, className); return; } // create item descriptor id = g_dialog.controlCount; g_dialog.controlCount++; g_dialog.controls = (struct nsControl*) HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, g_dialog.controls, g_dialog.controlCount * sizeof(struct nsControl)); if (!lstrcmpi(className, "BUTTON")) g_dialog.controls[id].type = NSCTL_BUTTON; else if (!lstrcmpi(className, "EDIT")) g_dialog.controls[id].type = NSCTL_EDIT; else if (!lstrcmpi(className, "COMBOBOX")) g_dialog.controls[id].type = NSCTL_COMBOBOX; else if (!lstrcmpi(className, "LISTBOX")) g_dialog.controls[id].type = NSCTL_LISTBOX; else if (!lstrcmpi(className, "RichEdit")) g_dialog.controls[id].type = NSCTL_RICHEDIT; else if (!lstrcmpi(className, "RICHEDIT_CLASS")) g_dialog.controls[id].type = NSCTL_RICHEDIT2; else if (!lstrcmpi(className, "STATIC")) g_dialog.controls[id].type = NSCTL_STATIC; else if (!lstrcmpi(className, "LINK")) g_dialog.controls[id].type = NSCTL_LINK; else g_dialog.controls[id].type = NSCTL_UNKNOWN; // apply rtl to style ConvertStyleToRTL(g_dialog.controls[id].type, &style, &exStyle); // create item's window hwItem = CreateWindowEx( exStyle, lstrcmpi(className, "LINK") ? className : "BUTTON", text, style, x, y, width, height, g_dialog.hwDialog, (HMENU) (1200 + id), g_hInstance, NULL); g_dialog.controls[id].window = hwItem; // remember id SetProp(hwItem, NSCONTROL_ID_PROP, (HANDLE) (id + 1)); // set font SendMessage(hwItem, WM_SETFONT, SendMessage(g_dialog.hwParent, WM_GETFONT, 0, 0), TRUE); // set the WndProc for the link control if(g_dialog.controls[id].type == NSCTL_LINK) g_dialog.controls[id].oldWndProc = (WNDPROC) SetWindowLong(hwItem, GWL_WNDPROC, (long) LinkWndProc); // push back result pushint((int) hwItem); // done HeapFree(GetProcessHeap(), 0, className); }
void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { // MSG Msg; WNDCLASS WndClass; HWND dhwPlacementRect; //HWND whwPlacementRect; HWND hwParent; //add by zhfi // HWND hwWindow; //add by zhfi //对话框尺寸 RECT drcPlacement; //父窗口窗口位置 RECT wrcPlacement; //WINDOWPLACEMENT *lpwndpl; int X, Y, nWidth, nHeight; DWORD dwExStyle, dwStyle; //LPCTSTR lpClassName, lpWindowName; char *lpClassName; char *lpWindowName; // s_plugins = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, g_stringsize * 2); lpClassName = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, g_stringsize * 2); lpWindowName = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NSWINDOWS_MAX_STRLEN * 2); EXDLL_INIT(); // MessageBox(hwndParent,"EXDLL_INIT",NULL,MB_OK); extra->RegisterPluginCallback(g_hInstance, PluginCallback); // MessageBox(hwndParent,"RegisterPluginCallback",NULL,MB_OK); //add by zhfi hwParent = (HWND) (popint()); // MessageBox(hwndParent,"hwParent = (HWND) (popint())",NULL,MB_OK); if (IsWindow(hwParent)) g_window.hwParent = hwParent; else g_window.hwParent = hwndParent; //获取窗口位置 if (GetWindowRect(g_window.hwParent, &wrcPlacement)) { X = wrcPlacement.left; Y = wrcPlacement.top; nWidth = wrcPlacement.right - wrcPlacement.left; nHeight = wrcPlacement.bottom - wrcPlacement.top; } else { X = 300; Y = 200; nWidth = 300; nHeight = 200; } g_pluginParms = NULL; // MessageBox(hwndParent,"g_pluginParms",NULL,MB_OK); // popstringn(lpWindowName, 0); dwExStyle = (DWORD) popint_or(); // MessageBox(hwndParent,lpWindowName,NULL,MB_OK); // popstringn(lpWindowName, 0); dwStyle = (DWORD) popint_or(); // MessageBox(hwndParent,lpWindowName,NULL,MB_OK); lpClassName = "#32770"; popstringn(lpWindowName, NSWINDOWS_MAX_STRLEN); // MessageBox(hwndParent,lpWindowName,NULL,MB_OK); { // MEMSET (&WndClass,0,sizeof(WNDCLASS)); // HeapAlloc(&WndClass, GMEM_MOVEABLE, sizeof(WNDCLASS)); WndClass.style = dwStyle; WndClass.lpfnWndProc = WindowProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = g_hInstance; WndClass.hIcon = LoadIcon(NULL, "END"); WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH)); WndClass.lpszMenuName = NULL; WndClass.lpszClassName = lpClassName; // MessageBox(hwndParent,"WndClass.lpszClassName",NULL,MB_OK); RegisterClass(&WndClass); } // MessageBox(hwndParent,"RegisterClass",NULL,MB_OK); g_window.hwWindow=CreateWindowEx(dwExStyle, WndClass.lpszClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hwParent, NULL, g_hInstance, NULL); if (g_window.hwWindow == NULL) { pushstring("error"); return; } // MessageBox(hwndParent,"CreateWindowEx",NULL,MB_OK); g_pluginParms = extra; dhwPlacementRect = GetDlgItem(hwndParent, popint()); if (IsWindow(dhwPlacementRect)) if (GetWindowRect(dhwPlacementRect, &drcPlacement)) { MapWindowPoints(NULL, hwndParent, (LPPOINT) &drcPlacement, 2); nWidth = drcPlacement.right - drcPlacement.left; nHeight = drcPlacement.bottom - drcPlacement.top; } X = X + (wrcPlacement.right - wrcPlacement.left - nWidth) / 2; Y = Y + (wrcPlacement.bottom - wrcPlacement.top - nHeight) / 2; SetWindowPos( g_window.hwWindow, 0, X, Y, nWidth, nHeight, SWP_NOZORDER | SWP_NOACTIVATE| SWP_HIDEWINDOW ); g_window.rtl = FALSE; g_window.controlCount = 0; g_window.controls = (struct nsControl*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 0); // g_window.callbacks.onBack = 0; ShowWindow(g_window.hwWindow, SW_HIDE); pushint((int) g_window.hwWindow); }