Mercurial > dwindows
comparison win/dw.c @ 1306:dbd507f42947
Added dw_debug() logging function which will output a message to the debugging console.
On Windows this uses OutputDebugMessage(), on Mac it uses NSLog() ...
The other platforms currently just dump it to stderr. Maybe more enhancements to come.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 03 Nov 2011 23:34:10 +0000 |
parents | 18a31ab94e3d |
children | e73c41653de8 |
comparison
equal
deleted
inserted
replaced
1305:18a31ab94e3d | 1306:dbd507f42947 |
---|---|
128 * the contents of the image to so it can be loaded by the Win32 API | 128 * the contents of the image to so it can be loaded by the Win32 API |
129 * We use _tempnam() which uses TMP env variable by default. It can be passed | 129 * We use _tempnam() which uses TMP env variable by default. It can be passed |
130 * an alternate temporary directory if TMP is not set, so we get the value | 130 * an alternate temporary directory if TMP is not set, so we get the value |
131 * of TEMP and store it here. | 131 * of TEMP and store it here. |
132 */ | 132 */ |
133 static char _dw_alternate_temp_dir[MAX_PATH]; | 133 static char _dw_alternate_temp_dir[MAX_PATH+1]; |
134 | |
135 FILE *dbgfp = NULL; | |
136 | 134 |
137 int main(int argc, char *argv[]); | 135 int main(int argc, char *argv[]); |
138 | 136 |
139 #define ICON_INDEX_LIMIT 200 | 137 #define ICON_INDEX_LIMIT 200 |
140 HICON lookup[200]; | 138 HICON lookup[200]; |
210 { WM_VSCROLL, DW_SIGNAL_VALUE_CHANGED }, | 208 { WM_VSCROLL, DW_SIGNAL_VALUE_CHANGED }, |
211 { TCN_SELCHANGE, DW_SIGNAL_SWITCH_PAGE }, | 209 { TCN_SELCHANGE, DW_SIGNAL_SWITCH_PAGE }, |
212 { LVN_COLUMNCLICK, DW_SIGNAL_COLUMN_CLICK }, | 210 { LVN_COLUMNCLICK, DW_SIGNAL_COLUMN_CLICK }, |
213 { TVN_ITEMEXPANDED,DW_SIGNAL_TREE_EXPAND } | 211 { TVN_ITEMEXPANDED,DW_SIGNAL_TREE_EXPAND } |
214 }; | 212 }; |
215 | |
216 static void _dw_log( char *format, ... ) | |
217 { | |
218 va_list args; | |
219 va_start(args, format); | |
220 if ( dbgfp != NULL ) | |
221 { | |
222 vfprintf( dbgfp, format, args ); | |
223 fflush( dbgfp ); | |
224 } | |
225 va_end(args); | |
226 } | |
227 | 213 |
228 #ifdef BUILD_DLL | 214 #ifdef BUILD_DLL |
229 void Win32_Set_Instance(HINSTANCE hInstance) | 215 void Win32_Set_Instance(HINSTANCE hInstance) |
230 { | 216 { |
231 DWInstance = hInstance; | 217 DWInstance = hInstance; |
3737 /* Initialize Security for named events and memory */ | 3723 /* Initialize Security for named events and memory */ |
3738 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION); | 3724 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION); |
3739 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE); | 3725 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE); |
3740 | 3726 |
3741 OleInitialize(NULL); | 3727 OleInitialize(NULL); |
3742 /* | 3728 |
3743 * Setup logging/debugging | |
3744 */ | |
3745 if ( (fname = getenv( "DWINDOWS_DEBUGFILE" ) ) != NULL ) | |
3746 { | |
3747 dbgfp = fopen( fname, "w" ); | |
3748 } | |
3749 /* | 3729 /* |
3750 * Get an alternate temporary directory in case TMP doesn't exist | 3730 * Get an alternate temporary directory in case TMP doesn't exist |
3751 */ | 3731 */ |
3752 if ( (alttmpdir = getenv( "TEMP" ) ) == NULL ) | 3732 if ( (alttmpdir = getenv( "TEMP" ) ) == NULL ) |
3753 { | 3733 { |
3754 strcpy( _dw_alternate_temp_dir, "c:\\tmp" ); | 3734 strcpy( _dw_alternate_temp_dir, "c:\\tmp" ); |
3755 } | 3735 } |
3756 else | 3736 else |
3757 { | 3737 { |
3758 strcpy( _dw_alternate_temp_dir, alttmpdir ); | 3738 strncpy( _dw_alternate_temp_dir, alttmpdir, MAX_PATH ); |
3759 } | 3739 } |
3760 /* | 3740 /* |
3761 * Get screen size. Used to make calls to dw_screen_width() | 3741 * Get screen size. Used to make calls to dw_screen_width() |
3762 * and dw_screen-height() quicker, but to alos limit the | 3742 * and dw_screen-height() quicker, but to alos limit the |
3763 * default size of windows. | 3743 * default size of windows. |
3918 free(dialog); | 3898 free(dialog); |
3919 return tmp; | 3899 return tmp; |
3920 } | 3900 } |
3921 | 3901 |
3922 /* | 3902 /* |
3903 * Displays a debug message on the console... | |
3904 * Parameters: | |
3905 * format: printf style format string. | |
3906 * ...: Additional variables for use in the format. | |
3907 */ | |
3908 void API dw_debug(char *format, ...) | |
3909 { | |
3910 va_list args; | |
3911 char outbuf[1025] = {0}; | |
3912 | |
3913 va_start(args, format); | |
3914 vsnprintf(outbuf, 1024, format, args); | |
3915 va_end(args); | |
3916 | |
3917 OutputDebugString(outbuf); | |
3918 } | |
3919 | |
3920 /* | |
3923 * Displays a Message Box with given text and title.. | 3921 * Displays a Message Box with given text and title.. |
3924 * Parameters: | 3922 * Parameters: |
3925 * title: The title of the message box. | 3923 * title: The title of the message box. |
3926 * format: printf style format string. | 3924 * format: printf style format string. |
3927 * ...: Additional variables for use in the format. | 3925 * ...: Additional variables for use in the format. |
3931 va_list args; | 3929 va_list args; |
3932 char outbuf[1024]; | 3930 char outbuf[1024]; |
3933 int rc; | 3931 int rc; |
3934 | 3932 |
3935 va_start(args, format); | 3933 va_start(args, format); |
3936 vsprintf(outbuf, format, args); | 3934 vsnprintf(outbuf, 1024, format, args); |
3937 va_end(args); | 3935 va_end(args); |
3938 | 3936 |
3939 rc = MessageBox(HWND_DESKTOP, outbuf, title, flags); | 3937 rc = MessageBox(HWND_DESKTOP, outbuf, title, flags); |
3940 if(rc == IDOK) | 3938 if(rc == IDOK) |
3941 return DW_MB_RETURN_OK; | 3939 return DW_MB_RETURN_OK; |
4100 LOGFONT _get_logfont(HDC hdc, char *fontname) | 4098 LOGFONT _get_logfont(HDC hdc, char *fontname) |
4101 { | 4099 { |
4102 int Italic, Bold; | 4100 int Italic, Bold; |
4103 char *myFontName; | 4101 char *myFontName; |
4104 int z, size = 9; | 4102 int z, size = 9; |
4105 LOGFONT lf; | 4103 LOGFONT lf = {0}; |
4106 | 4104 |
4107 for(z=0;z<strlen(fontname);z++) | 4105 for(z=0;z<strlen(fontname);z++) |
4108 { | 4106 { |
4109 if(fontname[z]=='.') | 4107 if(fontname[z]=='.') |
4110 break; | 4108 break; |
4131 myFontName = strdup(&fontname[z+1]); | 4129 myFontName = strdup(&fontname[z+1]); |
4132 if(Italic) | 4130 if(Italic) |
4133 myFontName[Italic] = 0; | 4131 myFontName[Italic] = 0; |
4134 if(Bold) | 4132 if(Bold) |
4135 myFontName[Bold] = 0; | 4133 myFontName[Bold] = 0; |
4136 strcpy(lf.lfFaceName, myFontName); | 4134 strncpy(lf.lfFaceName, myFontName, sizeof(lf.lfFaceName)-1); |
4137 free(myFontName); | 4135 free(myFontName); |
4138 return lf; | 4136 return lf; |
4139 } | 4137 } |
4140 | 4138 |
4141 /* Create a duplicate of an existing font handle | 4139 /* Create a duplicate of an existing font handle |
4234 else | 4232 else |
4235 { | 4233 { |
4236 cinfo = calloc(1, sizeof(ColorInfo)); | 4234 cinfo = calloc(1, sizeof(ColorInfo)); |
4237 cinfo->fore = cinfo->back = -1; | 4235 cinfo->fore = cinfo->back = -1; |
4238 | 4236 |
4239 strcpy(cinfo->fontname, fontname); | 4237 strncpy(cinfo->fontname, fontname, 127); |
4240 | 4238 |
4241 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); | 4239 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); |
4242 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo); | 4240 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo); |
4243 } | 4241 } |
4244 } | 4242 } |
4269 cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT; | 4267 cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT; |
4270 cf.lpLogFont = &lf; | 4268 cf.lpLogFont = &lf; |
4271 | 4269 |
4272 if(ChooseFont(&cf)) | 4270 if(ChooseFont(&cf)) |
4273 { | 4271 { |
4274 str = (char *)malloc( 100 ); | 4272 str = (char *)calloc( 101, 1 ); |
4275 if ( str ) | 4273 if ( str ) |
4276 { | 4274 { |
4277 int height; | 4275 int height; |
4278 HDC hdc = GetDC(NULL); | 4276 HDC hdc = GetDC(NULL); |
4279 | 4277 |
4281 bold = " Bold"; | 4279 bold = " Bold"; |
4282 if ( lf.lfItalic ) | 4280 if ( lf.lfItalic ) |
4283 italic = " Italic"; | 4281 italic = " Italic"; |
4284 height = MulDiv(abs(lf.lfHeight), 72, GetDeviceCaps (hdc, LOGPIXELSY)); | 4282 height = MulDiv(abs(lf.lfHeight), 72, GetDeviceCaps (hdc, LOGPIXELSY)); |
4285 ReleaseDC(NULL, hdc); | 4283 ReleaseDC(NULL, hdc); |
4286 sprintf( str, "%d.%s%s%s", height, lf.lfFaceName, bold, italic ); | 4284 _snprintf( str, 100, "%d.%s%s%s", height, lf.lfFaceName, bold, italic ); |
4287 } | 4285 } |
4288 } | 4286 } |
4289 return str; | 4287 return str; |
4290 } | 4288 } |
4291 | 4289 |
4316 } | 4314 } |
4317 } | 4315 } |
4318 oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); | 4316 oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); |
4319 if ( GetObject( oldfont, sizeof(lf), &lf ) ) | 4317 if ( GetObject( oldfont, sizeof(lf), &lf ) ) |
4320 { | 4318 { |
4321 str = (char *)malloc( 100 ); | 4319 str = (char *)calloc( 100, 1 ); |
4322 if ( str ) | 4320 if ( str ) |
4323 { | 4321 { |
4324 int height; | 4322 int height; |
4325 HDC hdc = GetDC(handle); | 4323 HDC hdc = GetDC(handle); |
4326 | 4324 |
4328 bold = " Bold"; | 4326 bold = " Bold"; |
4329 if ( lf.lfItalic ) | 4327 if ( lf.lfItalic ) |
4330 italic = " Italic"; | 4328 italic = " Italic"; |
4331 height = MulDiv(abs(lf.lfHeight), 72, GetDeviceCaps (hdc, LOGPIXELSY)); | 4329 height = MulDiv(abs(lf.lfHeight), 72, GetDeviceCaps (hdc, LOGPIXELSY)); |
4332 ReleaseDC(handle, hdc); | 4330 ReleaseDC(handle, hdc); |
4333 sprintf( str, "%d.%s%s%s", height, lf.lfFaceName, bold, italic ); | 4331 _snprintf( str, 100, "%d.%s%s%s", height, lf.lfFaceName, bold, italic ); |
4334 } | 4332 } |
4335 } | 4333 } |
4336 if ( oldfont ) | 4334 if ( oldfont ) |
4337 DeleteObject( oldfont ); | 4335 DeleteObject( oldfont ); |
4338 return str; | 4336 return str; |
4818 */ | 4816 */ |
4819 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) | 4817 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) |
4820 { | 4818 { |
4821 MENUITEMINFO mii; | 4819 MENUITEMINFO mii; |
4822 HMENU mymenu = (HMENU)menux; | 4820 HMENU mymenu = (HMENU)menux; |
4823 char buffer[30]; | 4821 char buffer[31] = {0}; |
4824 int is_checked, is_disabled; | 4822 int is_checked, is_disabled; |
4825 | 4823 |
4826 /* | 4824 /* |
4827 * Check if this is a menubar; if so get the menu object | 4825 * Check if this is a menubar; if so get the menu object |
4828 * for the menubar | 4826 * for the menubar |
4900 mii.dwTypeData = title; | 4898 mii.dwTypeData = title; |
4901 mii.cch = strlen(title); | 4899 mii.cch = strlen(title); |
4902 | 4900 |
4903 InsertMenuItem(mymenu, 65535, TRUE, &mii); | 4901 InsertMenuItem(mymenu, 65535, TRUE, &mii); |
4904 | 4902 |
4905 sprintf(buffer, "_dw_id%ld", id); | 4903 _snprintf(buffer, 30, "_dw_id%ld", id); |
4906 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)mymenu ); | 4904 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)mymenu ); |
4907 sprintf(buffer, "_dw_checkable%ld", id); | 4905 _snprintf(buffer, 30, "_dw_checkable%ld", id); |
4908 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)check ); | 4906 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)check ); |
4909 sprintf(buffer, "_dw_ischecked%ld", id); | 4907 _snprintf(buffer, 30, "_dw_ischecked%ld", id); |
4910 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_checked ); | 4908 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_checked ); |
4911 sprintf(buffer, "_dw_isdisabled%ld", id); | 4909 _snprintf(buffer, 30, "_dw_isdisabled%ld", id); |
4912 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_disabled ); | 4910 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_disabled ); |
4913 | 4911 |
4914 if (submenu) | 4912 if (submenu) |
4915 { | 4913 { |
4916 MENUINFO mi; | 4914 MENUINFO mi; |
4958 mii.fState |= MFS_UNCHECKED; | 4956 mii.fState |= MFS_UNCHECKED; |
4959 SetMenuItemInfo( mymenu, id, FALSE, &mii ); | 4957 SetMenuItemInfo( mymenu, id, FALSE, &mii ); |
4960 /* | 4958 /* |
4961 * Keep our internal state consistent | 4959 * Keep our internal state consistent |
4962 */ | 4960 */ |
4963 sprintf( buffer, "_dw_ischecked%ld", id ); | 4961 _snprintf( buffer, 30, "_dw_ischecked%ld", id ); |
4964 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)check ); | 4962 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)check ); |
4965 } | 4963 } |
4966 | 4964 |
4967 /* | 4965 /* |
4968 * Sets the state of a menu item. | 4966 * Sets the state of a menu item. |
4974 */ | 4972 */ |
4975 void API dw_menu_item_set_state( HMENUI menux, unsigned long id, unsigned long state) | 4973 void API dw_menu_item_set_state( HMENUI menux, unsigned long id, unsigned long state) |
4976 { | 4974 { |
4977 MENUITEMINFO mii; | 4975 MENUITEMINFO mii; |
4978 HMENU mymenu = (HMENU)menux; | 4976 HMENU mymenu = (HMENU)menux; |
4979 char buffer1[30],buffer2[30]; | 4977 char buffer1[31] = {0},buffer2[31] = {0}; |
4980 int check; | 4978 int check; |
4981 int disabled; | 4979 int disabled; |
4982 | 4980 |
4983 if (IsWindow(menux) && !IsMenu(mymenu)) | 4981 if (IsWindow(menux) && !IsMenu(mymenu)) |
4984 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu"); | 4982 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu"); |
4985 | 4983 |
4986 sprintf( buffer1, "_dw_ischecked%ld", id ); | 4984 _snprintf( buffer1, 30, "_dw_ischecked%ld", id ); |
4987 check = (int)dw_window_get_data( DW_HWND_OBJECT, buffer1 ); | 4985 check = (int)dw_window_get_data( DW_HWND_OBJECT, buffer1 ); |
4988 sprintf( buffer2, "_dw_isdisabled%ld", id ); | 4986 _snprintf( buffer2, 30, "_dw_isdisabled%ld", id ); |
4989 disabled = (int)dw_window_get_data( DW_HWND_OBJECT, buffer2 ); | 4987 disabled = (int)dw_window_get_data( DW_HWND_OBJECT, buffer2 ); |
4990 | 4988 |
4991 memset( &mii, 0, sizeof(mii) ); | 4989 memset( &mii, 0, sizeof(mii) ); |
4992 | 4990 |
4993 mii.cbSize = sizeof(MENUITEMINFO); | 4991 mii.cbSize = sizeof(MENUITEMINFO); |
6069 */ | 6067 */ |
6070 void API dw_window_disable(HWND handle) | 6068 void API dw_window_disable(HWND handle) |
6071 { | 6069 { |
6072 if(handle < (HWND)65536) | 6070 if(handle < (HWND)65536) |
6073 { | 6071 { |
6074 char buffer[30]; | 6072 char buffer[31] = {0}; |
6075 HMENU mymenu; | 6073 HMENU mymenu; |
6076 ULONG id = (ULONG)handle; | 6074 ULONG id = (ULONG)handle; |
6077 | 6075 |
6078 sprintf(buffer, "_dw_id%ld", id); | 6076 _snprintf(buffer, 30, "_dw_id%ld", id); |
6079 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer); | 6077 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer); |
6080 | 6078 |
6081 if(mymenu && IsMenu(mymenu)) | 6079 if(mymenu && IsMenu(mymenu)) |
6082 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_DISABLED); | 6080 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_DISABLED); |
6083 } | 6081 } |
6092 */ | 6090 */ |
6093 void API dw_window_enable(HWND handle) | 6091 void API dw_window_enable(HWND handle) |
6094 { | 6092 { |
6095 if(handle < (HWND)65536) | 6093 if(handle < (HWND)65536) |
6096 { | 6094 { |
6097 char buffer[30]; | 6095 char buffer[31] = {0}; |
6098 HMENU mymenu; | 6096 HMENU mymenu; |
6099 ULONG id = (ULONG)handle; | 6097 ULONG id = (ULONG)handle; |
6100 | 6098 |
6101 sprintf(buffer, "_dw_id%ld", id); | 6099 _snprintf(buffer, 30, "_dw_id%ld", id); |
6102 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer); | 6100 mymenu = (HMENU)dw_window_get_data(DW_HWND_OBJECT, buffer); |
6103 | 6101 |
6104 if(mymenu && IsMenu(mymenu)) | 6102 if(mymenu && IsMenu(mymenu)) |
6105 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_ENABLED); | 6103 dw_menu_item_set_state((HMENUI)mymenu, id, DW_MIS_ENABLED); |
6106 } | 6104 } |
7367 * handle: Handle to the spinbutton to be set. | 7365 * handle: Handle to the spinbutton to be set. |
7368 * position: Current value of the spinbutton. | 7366 * position: Current value of the spinbutton. |
7369 */ | 7367 */ |
7370 void API dw_spinbutton_set_pos(HWND handle, long position) | 7368 void API dw_spinbutton_set_pos(HWND handle, long position) |
7371 { | 7369 { |
7372 char tmpbuf[100]; | 7370 char tmpbuf[101] = {0}; |
7373 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 7371 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
7374 | 7372 |
7375 sprintf(tmpbuf, "%ld", position); | 7373 _snprintf(tmpbuf, 100, "%ld", position); |
7376 | 7374 |
7377 if(cinfo && cinfo->buddy) | 7375 if(cinfo && cinfo->buddy) |
7378 SetWindowText(cinfo->buddy, tmpbuf); | 7376 SetWindowText(cinfo->buddy, tmpbuf); |
7379 | 7377 |
7380 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position); | 7378 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position); |
8047 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | 8045 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) |
8048 { | 8046 { |
8049 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 8047 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
8050 ULONG *flags; | 8048 ULONG *flags; |
8051 LV_ITEM lvi; | 8049 LV_ITEM lvi; |
8052 char textbuffer[100], *destptr = textbuffer; | 8050 char textbuffer[101] = {0}, *destptr = textbuffer; |
8053 int item = 0; | 8051 int item = 0; |
8054 | 8052 |
8055 if(pointer) | 8053 if(pointer) |
8056 { | 8054 { |
8057 item = (int)dw_window_get_data(handle, "_dw_insertitem"); | 8055 item = (int)dw_window_get_data(handle, "_dw_insertitem"); |
8089 } | 8087 } |
8090 else if(flags[column] & DW_CFA_ULONG) | 8088 else if(flags[column] & DW_CFA_ULONG) |
8091 { | 8089 { |
8092 ULONG tmp = *((ULONG *)data); | 8090 ULONG tmp = *((ULONG *)data); |
8093 | 8091 |
8094 sprintf(textbuffer, "%lu", tmp); | 8092 _snprintf(textbuffer, 100, "%lu", tmp); |
8095 | 8093 |
8096 lvi.pszText = textbuffer; | 8094 lvi.pszText = textbuffer; |
8097 lvi.cchTextMax = strlen(textbuffer); | 8095 lvi.cchTextMax = strlen(textbuffer); |
8098 } | 8096 } |
8099 else if(flags[column] & DW_CFA_DATE) | 8097 else if(flags[column] & DW_CFA_DATE) |
9886 * exitcode: Exit code reported to the operating system. | 9884 * exitcode: Exit code reported to the operating system. |
9887 */ | 9885 */ |
9888 void API dw_exit(int exitcode) | 9886 void API dw_exit(int exitcode) |
9889 { | 9887 { |
9890 OleUninitialize(); | 9888 OleUninitialize(); |
9891 if ( dbgfp != NULL ) | |
9892 { | |
9893 fclose( dbgfp ); | |
9894 } | |
9895 exit(exitcode); | 9889 exit(exitcode); |
9896 } | 9890 } |
9897 | 9891 |
9898 /* | 9892 /* |
9899 * Creates a splitbar window (widget) with given parameters. | 9893 * Creates a splitbar window (widget) with given parameters. |
10228 * | 10222 * |
10229 */ | 10223 */ |
10230 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) | 10224 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) |
10231 { | 10225 { |
10232 OPENFILENAME of; | 10226 OPENFILENAME of; |
10233 char filenamebuf[1001] = ""; | 10227 char filenamebuf[1001] = {0}; |
10234 char filterbuf[1000] = ""; | 10228 char filterbuf[1001] = {0}; |
10235 int rc; | 10229 int rc; |
10236 | 10230 |
10237 BROWSEINFO bi; | 10231 BROWSEINFO bi; |
10238 TCHAR szDir[MAX_PATH]; | 10232 TCHAR szDir[MAX_PATH]; |
10239 LPITEMIDLIST pidl; | 10233 LPITEMIDLIST pidl; |
10256 pidl = SHBrowseForFolder(&bi); | 10250 pidl = SHBrowseForFolder(&bi); |
10257 if (pidl) | 10251 if (pidl) |
10258 { | 10252 { |
10259 if (SHGetPathFromIDList(pidl,szDir)) | 10253 if (SHGetPathFromIDList(pidl,szDir)) |
10260 { | 10254 { |
10261 strcpy(filenamebuf,szDir); | 10255 strncpy(filenamebuf,szDir,1000); |
10262 } | 10256 } |
10263 | 10257 |
10264 // In C++: pMalloc->Free(pidl); pMalloc->Release(); | 10258 // In C++: pMalloc->Free(pidl); pMalloc->Release(); |
10265 pMalloc->lpVtbl->Free(pMalloc,pidl); | 10259 pMalloc->lpVtbl->Free(pMalloc,pidl); |
10266 pMalloc->lpVtbl->Release(pMalloc); | 10260 pMalloc->lpVtbl->Release(pMalloc); |
10793 if ((message = _findsigmessage(signame)) != 0) | 10787 if ((message = _findsigmessage(signame)) != 0) |
10794 { | 10788 { |
10795 /* Handle special case of the menu item */ | 10789 /* Handle special case of the menu item */ |
10796 if (message == WM_COMMAND && window < (HWND)65536) | 10790 if (message == WM_COMMAND && window < (HWND)65536) |
10797 { | 10791 { |
10798 char buffer[15]; | 10792 char buffer[16]; |
10799 HWND owner; | 10793 HWND owner; |
10800 | 10794 |
10801 sprintf(buffer, "_dw_id%d", (int)window); | 10795 _snprintf(buffer, 15, "_dw_id%d", (int)window); |
10802 owner = (HWND)dw_window_get_data(DW_HWND_OBJECT, buffer); | 10796 owner = (HWND)dw_window_get_data(DW_HWND_OBJECT, buffer); |
10803 | 10797 |
10804 /* Make sure there are no dupes from popups */ | 10798 /* Make sure there are no dupes from popups */ |
10805 dw_signal_disconnect_by_window(window); | 10799 dw_signal_disconnect_by_window(window); |
10806 | 10800 |