Mercurial > dwindows
comparison win/dw.c @ 912:0c39705ddd4a
Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
Windows 2000 and above are supported, so added a macro to test for XP or higher to enable advanced features.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 21 Apr 2011 11:27:09 +0000 |
parents | 3e393a9375c4 |
children | 81059acce901 |
comparison
equal
deleted
inserted
replaced
911:1ac9669caf86 | 912:0c39705ddd4a |
---|---|
42 static HFONT DefaultBoldFont; | 42 static HFONT DefaultBoldFont; |
43 static LOGFONT lfDefaultBoldFont = { 0 }; | 43 static LOGFONT lfDefaultBoldFont = { 0 }; |
44 | 44 |
45 #define PACKVERSION(major,minor) MAKELONG(minor,major) | 45 #define PACKVERSION(major,minor) MAKELONG(minor,major) |
46 | 46 |
47 #define IS_IE5PLUS (dwComctlVer >= PACKVERSION(5,80)) | 47 #define IS_XPPLUS (dwComctlVer >= PACKVERSION(5,82)) |
48 #define IS_WINNTOR95 (((LOBYTE(LOWORD(dwVersion))) < 5) && (HIBYTE(LOWORD(dwVersion)) < 10)) | |
49 | 48 |
50 #ifndef MIN | 49 #ifndef MIN |
51 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) | 50 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
52 #endif | 51 #endif |
53 | |
54 static BOOL (WINAPI* MyGetMenuInfo)(HMENU, LPCMENUINFO) = 0; | |
55 static BOOL (WINAPI* MySetMenuInfo)(HMENU, LPCMENUINFO) = 0; | |
56 | 52 |
57 FILE *dbgfp = NULL; | 53 FILE *dbgfp = NULL; |
58 | 54 |
59 int main(int argc, char *argv[]); | 55 int main(int argc, char *argv[]); |
60 | 56 |
567 return TRUE; | 563 return TRUE; |
568 } | 564 } |
569 | 565 |
570 void _free_menu_data(HMENU menu) | 566 void _free_menu_data(HMENU menu) |
571 { | 567 { |
572 if (!IS_WINNTOR95 ) | 568 int i, count = GetMenuItemCount(menu); |
573 { | 569 |
574 int i, count = GetMenuItemCount(menu); | 570 for(i=0;i<count;i++) |
575 | 571 { |
576 for(i=0;i<count;i++) | 572 MENUITEMINFO mii; |
577 { | 573 |
578 MENUITEMINFO mii; | 574 mii.cbSize = sizeof(MENUITEMINFO); |
579 | 575 mii.fMask = MIIM_SUBMENU; |
580 mii.cbSize = sizeof(MENUITEMINFO); | 576 |
581 mii.fMask = MIIM_SUBMENU; | 577 if ( GetMenuItemInfo( menu, i, TRUE, &mii ) && mii.hSubMenu ) |
582 | |
583 if ( GetMenuItemInfo( menu, i, TRUE, &mii ) | |
584 && mii.hSubMenu ) | |
585 _free_menu_data(mii.hSubMenu); | 578 _free_menu_data(mii.hSubMenu); |
586 } | 579 } |
587 } | 580 dw_signal_disconnect_by_name((HWND)menu, DW_SIGNAL_CLICKED); |
588 dw_signal_disconnect_by_name((HWND)menu, DW_SIGNAL_CLICKED); | |
589 } | 581 } |
590 | 582 |
591 /* Convert to our internal color scheme */ | 583 /* Convert to our internal color scheme */ |
592 ULONG _internal_color(ULONG color) | 584 ULONG _internal_color(ULONG color) |
593 { | 585 { |
1605 MENUINFO mi; | 1597 MENUINFO mi; |
1606 | 1598 |
1607 mi.cbSize = sizeof(MENUINFO); | 1599 mi.cbSize = sizeof(MENUINFO); |
1608 mi.fMask = MIM_MENUDATA; | 1600 mi.fMask = MIM_MENUDATA; |
1609 | 1601 |
1610 if ( MyGetMenuInfo( menu, &mi ) ) | 1602 if ( GetMenuInfo( menu, &mi ) ) |
1611 return (HMENU)mi.dwMenuData; | 1603 return (HMENU)mi.dwMenuData; |
1612 return (HMENU)0; | 1604 return (HMENU)0; |
1613 } | 1605 } |
1614 | 1606 |
1615 /* Find the desktop window handle */ | 1607 /* Find the desktop window handle */ |
2125 { | 2117 { |
2126 result = listboxselectfunc(tmp->window, dw_listbox_selected(tmp->window), tmp->data); | 2118 result = listboxselectfunc(tmp->window, dw_listbox_selected(tmp->window), tmp->data); |
2127 tmp = NULL; | 2119 tmp = NULL; |
2128 } | 2120 } |
2129 } | 2121 } |
2130 else if (!IS_WINNTOR95 && tmp->id && passthru == tmp->id) | 2122 else if (tmp->id && passthru == tmp->id) |
2131 { | 2123 { |
2132 HMENU hwndmenu = GetMenu(hWnd), menuowner = _menu_owner((HMENU)tmp->window); | 2124 HMENU hwndmenu = GetMenu(hWnd), menuowner = _menu_owner((HMENU)tmp->window); |
2133 | 2125 |
2134 if (menuowner == hwndmenu || !menuowner) | 2126 if (menuowner == hwndmenu || !menuowner) |
2135 { | 2127 { |
2726 | 2718 |
2727 GetWindowText(cinfo->buddy, tempbuf, 99); | 2719 GetWindowText(cinfo->buddy, tempbuf, 99); |
2728 | 2720 |
2729 position = atol(tempbuf); | 2721 position = atol(tempbuf); |
2730 | 2722 |
2731 if(IS_IE5PLUS) | 2723 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position); |
2732 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position); | |
2733 else | |
2734 SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0)); | |
2735 } | 2724 } |
2736 } | 2725 } |
2737 break; | 2726 break; |
2738 } | 2727 } |
2739 } | 2728 } |
2916 { | 2905 { |
2917 if(cinfo->buddy) | 2906 if(cinfo->buddy) |
2918 { | 2907 { |
2919 long val; | 2908 long val; |
2920 | 2909 |
2921 if(IS_IE5PLUS) | 2910 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0); |
2922 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0); | |
2923 else | |
2924 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0); | |
2925 | 2911 |
2926 sprintf(tmpbuf, "%ld", val); | 2912 sprintf(tmpbuf, "%ld", val); |
2927 SetWindowText(hWnd, tmpbuf); | 2913 SetWindowText(hWnd, tmpbuf); |
2928 } | 2914 } |
2929 } | 2915 } |
3820 _hBrush[z] = CreateSolidBrush(_foreground[z]); | 3806 _hBrush[z] = CreateSolidBrush(_foreground[z]); |
3821 _clipboard_contents[z] = NULL; | 3807 _clipboard_contents[z] = NULL; |
3822 _PointerOnWnd[z] = 0; | 3808 _PointerOnWnd[z] = 0; |
3823 } | 3809 } |
3824 | 3810 |
3825 if ( !IS_WINNTOR95 ) | |
3826 { | |
3827 /* Get function pointers for the Win2k/98 menu functions */ | |
3828 HANDLE huser = LoadLibrary("user32"); | |
3829 | |
3830 MyGetMenuInfo = (void*)GetProcAddress(huser, "GetMenuInfo"); | |
3831 MySetMenuInfo = (void*)GetProcAddress(huser, "SetMenuInfo"); | |
3832 FreeLibrary(huser); | |
3833 } | |
3834 | |
3835 /* Initialize Security for named events and memory */ | 3811 /* Initialize Security for named events and memory */ |
3836 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION); | 3812 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION); |
3837 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE); | 3813 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE); |
3838 | 3814 |
3839 OleInitialize(NULL); | 3815 OleInitialize(NULL); |
4093 */ | 4069 */ |
4094 int API dw_window_destroy(HWND handle) | 4070 int API dw_window_destroy(HWND handle) |
4095 { | 4071 { |
4096 HWND parent = GetParent(handle); | 4072 HWND parent = GetParent(handle); |
4097 Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA); | 4073 Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA); |
4098 | 4074 HMENU menu = GetMenu(handle); |
4099 if(!IS_WINNTOR95) | 4075 |
4100 { | 4076 if(menu) |
4101 HMENU menu = GetMenu(handle); | 4077 _free_menu_data(menu); |
4102 | |
4103 if(menu) | |
4104 _free_menu_data(menu); | |
4105 } | |
4106 | 4078 |
4107 if(parent != HWND_DESKTOP && thisbox && thisbox->count) | 4079 if(parent != HWND_DESKTOP && thisbox && thisbox->count) |
4108 { | 4080 { |
4109 int z, index = -1; | 4081 int z, index = -1; |
4110 Item *tmpitem, *thisitem = thisbox->items; | 4082 Item *tmpitem, *thisitem = thisbox->items; |
4792 * location: Handle of a window frame to be attached to. | 4764 * location: Handle of a window frame to be attached to. |
4793 */ | 4765 */ |
4794 HMENUI API dw_menubar_new(HWND location) | 4766 HMENUI API dw_menubar_new(HWND location) |
4795 { | 4767 { |
4796 HMENUI tmp; | 4768 HMENUI tmp; |
4769 MENUINFO mi; | |
4797 | 4770 |
4798 tmp = (HMENUI)CreateMenu(); | 4771 tmp = (HMENUI)CreateMenu(); |
4799 | 4772 |
4800 if (!IS_WINNTOR95) | 4773 mi.cbSize = sizeof(MENUINFO); |
4801 { | 4774 mi.fMask = MIM_MENUDATA; |
4802 MENUINFO mi; | 4775 mi.dwMenuData = (ULONG_PTR)1; |
4803 | 4776 |
4804 mi.cbSize = sizeof(MENUINFO); | 4777 SetMenuInfo( (HMENU)tmp, &mi ); |
4805 mi.fMask = MIM_MENUDATA; | |
4806 mi.dwMenuData = (ULONG_PTR)1; | |
4807 | |
4808 MySetMenuInfo( (HMENU)tmp, &mi ); | |
4809 } | |
4810 | 4778 |
4811 dw_window_set_data(location, "_dw_menu", (void *)tmp); | 4779 dw_window_set_data(location, "_dw_menu", (void *)tmp); |
4812 | 4780 |
4813 SetMenu(location, (HMENU)tmp); | 4781 SetMenu(location, (HMENU)tmp); |
4814 return location; | 4782 return location; |
4910 sprintf(buffer, "_dw_ischecked%ld", id); | 4878 sprintf(buffer, "_dw_ischecked%ld", id); |
4911 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_checked ); | 4879 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_checked ); |
4912 sprintf(buffer, "_dw_isdisabled%ld", id); | 4880 sprintf(buffer, "_dw_isdisabled%ld", id); |
4913 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_disabled ); | 4881 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_disabled ); |
4914 | 4882 |
4915 if (!IS_WINNTOR95) | 4883 if (submenu) |
4916 { | 4884 { |
4917 /* According to the docs this will only work on Win2k/98 and above */ | 4885 MENUINFO mi; |
4918 if (submenu) | 4886 |
4919 { | 4887 mi.cbSize = sizeof(MENUINFO); |
4920 MENUINFO mi; | 4888 mi.fMask = MIM_MENUDATA; |
4921 | 4889 mi.dwMenuData = (ULONG_PTR)mymenu; |
4922 mi.cbSize = sizeof(MENUINFO); | 4890 |
4923 mi.fMask = MIM_MENUDATA; | 4891 SetMenuInfo( (HMENU)submenu, &mi ); |
4924 mi.dwMenuData = (ULONG_PTR)mymenu; | |
4925 | |
4926 MySetMenuInfo( (HMENU)submenu, &mi ); | |
4927 } | |
4928 } | 4892 } |
4929 | 4893 |
4930 if (IsWindow(menux) && !IsMenu((HMENU)menux)) | 4894 if (IsWindow(menux) && !IsMenu((HMENU)menux)) |
4931 DrawMenuBar(menux); | 4895 DrawMenuBar(menux); |
4932 return (HWND)id; | 4896 return (HWND)id; |
5140 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc); | 5104 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc); |
5141 cinfo->cinfo.fore = cinfo->cinfo.back = -1; | 5105 cinfo->cinfo.fore = cinfo->cinfo.back = -1; |
5142 | 5106 |
5143 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); | 5107 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); |
5144 dw_window_set_font(tmp, DefaultFont); | 5108 dw_window_set_font(tmp, DefaultFont); |
5109 /* If we are running XP or higher... */ | |
5110 if(IS_XPPLUS) | |
5111 { | |
5112 /* Enable double buffering to prevent flicker */ | |
5113 ListView_SetExtendedListViewStyleEx(tmp, LVS_EX_DOUBLEBUFFER, LVS_EX_DOUBLEBUFFER); | |
5114 } | |
5145 return tmp; | 5115 return tmp; |
5146 } | 5116 } |
5147 | 5117 |
5148 /* | 5118 /* |
5149 * Create a tree object to be packed. | 5119 * Create a tree object to be packed. |
7212 sprintf(tmpbuf, "%ld", position); | 7182 sprintf(tmpbuf, "%ld", position); |
7213 | 7183 |
7214 if(cinfo && cinfo->buddy) | 7184 if(cinfo && cinfo->buddy) |
7215 SetWindowText(cinfo->buddy, tmpbuf); | 7185 SetWindowText(cinfo->buddy, tmpbuf); |
7216 | 7186 |
7217 if(IS_IE5PLUS) | 7187 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position); |
7218 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position); | |
7219 else | |
7220 SendMessage(handle, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0)); | |
7221 } | 7188 } |
7222 | 7189 |
7223 /* | 7190 /* |
7224 * Sets the spinbutton limits. | 7191 * Sets the spinbutton limits. |
7225 * Parameters: | 7192 * Parameters: |
7227 * position: Current value of the spinbutton. | 7194 * position: Current value of the spinbutton. |
7228 * position: Current value of the spinbutton. | 7195 * position: Current value of the spinbutton. |
7229 */ | 7196 */ |
7230 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) | 7197 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) |
7231 { | 7198 { |
7232 if(IS_IE5PLUS) | 7199 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper); |
7233 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper); | |
7234 else | |
7235 SendMessage(handle, UDM_SETRANGE32, (WPARAM)((short)lower), | |
7236 (LPARAM)((short)upper)); | |
7237 } | 7200 } |
7238 | 7201 |
7239 /* | 7202 /* |
7240 * Sets the entryfield character limit. | 7203 * Sets the entryfield character limit. |
7241 * Parameters: | 7204 * Parameters: |
7252 * Parameters: | 7215 * Parameters: |
7253 * handle: Handle to the spinbutton to be queried. | 7216 * handle: Handle to the spinbutton to be queried. |
7254 */ | 7217 */ |
7255 long API dw_spinbutton_get_pos(HWND handle) | 7218 long API dw_spinbutton_get_pos(HWND handle) |
7256 { | 7219 { |
7257 if(IS_IE5PLUS) | 7220 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0); |
7258 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0); | |
7259 else | |
7260 return (long)SendMessage(handle, UDM_GETPOS, 0, 0); | |
7261 } | 7221 } |
7262 | 7222 |
7263 /* | 7223 /* |
7264 * Returns the state of the checkbox. | 7224 * Returns the state of the checkbox. |
7265 * Parameters: | 7225 * Parameters: |