comparison win/dw.c @ 75:c629838d9805

Updated to latest DW, and updated the Makefile to install the header files along with the libraries.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 13 Mar 2002 17:35:36 +0000
parents 2f339dd13496
children 8082cb0e7c2e
comparison
equal deleted inserted replaced
74:f794f2baabf2 75:c629838d9805
8 #define _WIN32_IE 0x0500 8 #define _WIN32_IE 0x0500
9 #define WINVER 0x400 9 #define WINVER 0x400
10 #include <windows.h> 10 #include <windows.h>
11 #include <windowsx.h> 11 #include <windowsx.h>
12 #include <commctrl.h> 12 #include <commctrl.h>
13 #include <shlwapi.h>
13 #include <stdlib.h> 14 #include <stdlib.h>
14 #include <string.h> 15 #include <string.h>
15 #include <stdio.h> 16 #include <stdio.h>
16 #include <process.h> 17 #include <process.h>
17 #include <time.h> 18 #include <time.h>
23 24
24 HWND hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL; 25 HWND hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL;
25 26
26 HINSTANCE DWInstance = NULL; 27 HINSTANCE DWInstance = NULL;
27 28
28 DWORD dwVersion = 0; 29 DWORD dwVersion = 0, dwComctlVer = 0;
29 DWTID _dwtid = -1; 30 DWTID _dwtid = -1;
30 31
31 /* I should probably check the actual file version, but this will do for now */ 32 #define PACKVERSION(major,minor) MAKELONG(minor,major)
32 #define IS_WIN98PLUS (LOBYTE(LOWORD(dwVersion)) > 4 || \ 33
33 (LOBYTE(LOWORD(dwVersion)) == 4 && HIBYTE(LOWORD(dwVersion)) > 0)) 34 #define IS_IE5PLUS (dwComctlVer >= PACKVERSION(5,80))
34 35
35 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", 36 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
36 "Sep", "Oct", "Nov", "Dec" }; 37 "Sep", "Oct", "Nov", "Dec" };
37 38
38 int main(int argc, char *argv[]); 39 int main(int argc, char *argv[]);
237 isnt = 1; 238 isnt = 1;
238 else 239 else
239 isnt = 0; 240 isnt = 0;
240 } 241 }
241 return isnt; 242 return isnt;
243 }
244
245 DWORD GetDllVersion(LPCTSTR lpszDllName)
246 {
247
248 HINSTANCE hinstDll;
249 DWORD dwVersion = 0;
250
251 hinstDll = LoadLibrary(lpszDllName);
252
253 if(hinstDll)
254 {
255 DLLGETVERSIONPROC pDllGetVersion;
256
257 pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
258
259 /* Because some DLLs might not implement this function, you
260 * must test for it explicitly. Depending on the particular
261 * DLL, the lack of a DllGetVersion function can be a useful
262 * indicator of the version.
263 */
264 if(pDllGetVersion)
265 {
266 DLLVERSIONINFO dvi;
267 HRESULT hr;
268
269 ZeroMemory(&dvi, sizeof(dvi));
270 dvi.cbSize = sizeof(dvi);
271
272 hr = (*pDllGetVersion)(&dvi);
273
274 if(SUCCEEDED(hr))
275 {
276 dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
277 }
278 }
279
280 FreeLibrary(hinstDll);
281 }
282 return dwVersion;
242 } 283 }
243 284
244 /* This function adds a signal handler callback into the linked list. 285 /* This function adds a signal handler callback into the linked list.
245 */ 286 */
246 void _new_signal(ULONG message, HWND window, void *signalfunction, void *data) 287 void _new_signal(ULONG message, HWND window, void *signalfunction, void *data)
1743 1784
1744 GetWindowText(cinfo->buddy, tempbuf, 99); 1785 GetWindowText(cinfo->buddy, tempbuf, 99);
1745 1786
1746 position = atol(tempbuf); 1787 position = atol(tempbuf);
1747 1788
1748 if(IS_WIN98PLUS) 1789 if(IS_IE5PLUS)
1749 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position); 1790 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position);
1750 else 1791 else
1751 SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0)); 1792 SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0));
1752 } 1793 }
1753 } 1794 }
1874 1915
1875 GetWindowText(cinfo->buddy, tmpbuf, 99); 1916 GetWindowText(cinfo->buddy, tmpbuf, 99);
1876 1917
1877 position = atol(tmpbuf); 1918 position = atol(tmpbuf);
1878 1919
1879 if(IS_WIN98PLUS) 1920 if(IS_IE5PLUS)
1880 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0); 1921 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0);
1881 else 1922 else
1882 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0); 1923 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0);
1883 1924
1884 if(val != position) 1925 if(val != position)
2733 #ifdef DWDEBUG 2774 #ifdef DWDEBUG
2734 f = fopen("dw.log", "wt"); 2775 f = fopen("dw.log", "wt");
2735 #endif 2776 #endif
2736 /* We need the version to check capability like up-down controls */ 2777 /* We need the version to check capability like up-down controls */
2737 dwVersion = GetVersion(); 2778 dwVersion = GetVersion();
2779 dwComctlVer = GetDllVersion(TEXT("comctl32.dll"));
2738 2780
2739 for(z=0;z<THREAD_LIMIT;z++) 2781 for(z=0;z<THREAD_LIMIT;z++)
2740 { 2782 {
2741 _foreground[z] = RGB(128,128,128); 2783 _foreground[z] = RGB(128,128,128);
2742 _background[z] = 0; 2784 _background[z] = 0;
2743 _hPen[z] = CreatePen(PS_SOLID, 1, _foreground[z]); 2785 _hPen[z] = CreatePen(PS_SOLID, 1, _foreground[z]);
2744 _hBrush[z] = CreateSolidBrush(_foreground[z]); 2786 _hBrush[z] = CreateSolidBrush(_foreground[z]);
2745 } 2787 }
2746 2788
2747 #if 0
2748 {
2749 DWORD dwResult = GetSysColor(COLOR_3DFACE);
2750
2751 dw_messagebox("DW",
2752 "Window color: {%x, %x, %x}",
2753 GetRValue(dwResult),
2754 GetGValue(dwResult),
2755 GetBValue(dwResult));
2756 }
2757 #endif
2758 return 0; 2789 return 0;
2759 } 2790 }
2760 2791
2761 /* 2792 /*
2762 * Runs a message loop for Dynamic Windows. 2793 * Runs a message loop for Dynamic Windows.
4117 * handle: Handle to the window. 4148 * handle: Handle to the window.
4118 * text: The text associsated with a given window. 4149 * text: The text associsated with a given window.
4119 */ 4150 */
4120 void dw_window_set_text(HWND handle, char *text) 4151 void dw_window_set_text(HWND handle, char *text)
4121 { 4152 {
4153 char tmpbuf[100];
4154
4155 GetClassName(handle, tmpbuf, 99);
4156
4122 SetWindowText(handle, text); 4157 SetWindowText(handle, text);
4158
4159 /* Combobox */
4160 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0)
4161 SendMessage(handle, CB_SETEDITSEL, 0, MAKELPARAM(-1, 0));
4123 } 4162 }
4124 4163
4125 /* 4164 /*
4126 * Gets the text used for a given window. 4165 * Gets the text used for a given window.
4127 * Parameters: 4166 * Parameters:
5087 sprintf(tmpbuf, "%d", position); 5126 sprintf(tmpbuf, "%d", position);
5088 5127
5089 if(cinfo && cinfo->buddy) 5128 if(cinfo && cinfo->buddy)
5090 SetWindowText(cinfo->buddy, tmpbuf); 5129 SetWindowText(cinfo->buddy, tmpbuf);
5091 5130
5092 if(IS_WIN98PLUS) 5131 if(IS_IE5PLUS)
5093 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position); 5132 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
5094 else 5133 else
5095 SendMessage(handle, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0)); 5134 SendMessage(handle, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0));
5096 } 5135 }
5097 5136
5102 * position: Current value of the spinbutton. 5141 * position: Current value of the spinbutton.
5103 * position: Current value of the spinbutton. 5142 * position: Current value of the spinbutton.
5104 */ 5143 */
5105 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) 5144 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
5106 { 5145 {
5107 if(IS_WIN98PLUS) 5146 if(IS_IE5PLUS)
5108 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper); 5147 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
5109 else 5148 else
5110 SendMessage(handle, UDM_SETRANGE32, (WPARAM)((short)lower), 5149 SendMessage(handle, UDM_SETRANGE32, (WPARAM)((short)lower),
5111 (LPARAM)((short)upper)); 5150 (LPARAM)((short)upper));
5112 } 5151 }
5127 * Parameters: 5166 * Parameters:
5128 * handle: Handle to the spinbutton to be queried. 5167 * handle: Handle to the spinbutton to be queried.
5129 */ 5168 */
5130 long dw_spinbutton_query(HWND handle) 5169 long dw_spinbutton_query(HWND handle)
5131 { 5170 {
5132 if(IS_WIN98PLUS) 5171 if(IS_IE5PLUS)
5133 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0); 5172 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
5134 else 5173 else
5135 return (long)SendMessage(handle, UDM_GETPOS, 0, 0); 5174 return (long)SendMessage(handle, UDM_GETPOS, 0, 0);
5136 } 5175 }
5137 5176
5355 * handle: Handle to the window (widget) to be cleared. 5394 * handle: Handle to the window (widget) to be cleared.
5356 * item: Handle to node to be deleted. 5395 * item: Handle to node to be deleted.
5357 */ 5396 */
5358 void dw_tree_delete(HWND handle, HWND item) 5397 void dw_tree_delete(HWND handle, HWND item)
5359 { 5398 {
5360 if((HTREEITEM)item == TVI_ROOT) 5399 if((HTREEITEM)item == TVI_ROOT || !item)
5361 return; 5400 return;
5362 5401
5363 TreeView_DeleteItem(handle, (HTREEITEM)item); 5402 TreeView_DeleteItem(handle, (HTREEITEM)item);
5364 } 5403 }
5365 5404