Mercurial > dwindows
comparison win/dw.c @ 1617:f8d1da63fb77
Add code to allow building DW.DLL as Unicode on Windows.
DWCOMPAT.DLL currently is still built ANSI for now.
Will add -DUNICODE and -D_UNICODE to the flags when it is stable.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 27 Mar 2012 08:51:14 +0000 |
parents | 702de58e9ef8 |
children | 428148fd0976 |
comparison
equal
deleted
inserted
replaced
1616:bbef5d25efa0 | 1617:f8d1da63fb77 |
---|---|
12 #include <windowsx.h> | 12 #include <windowsx.h> |
13 #include <commctrl.h> | 13 #include <commctrl.h> |
14 #include <shlwapi.h> | 14 #include <shlwapi.h> |
15 #include <shlobj.h> | 15 #include <shlobj.h> |
16 #include <userenv.h> | 16 #include <userenv.h> |
17 #include <wchar.h> | |
17 #include <stdlib.h> | 18 #include <stdlib.h> |
18 #include <string.h> | 19 #include <string.h> |
19 #include <stdio.h> | 20 #include <stdio.h> |
20 #include <process.h> | 21 #include <process.h> |
21 #include <malloc.h> | 22 #include <malloc.h> |
29 #ifdef AEROGLASS | 30 #ifdef AEROGLASS |
30 #include <uxtheme.h> | 31 #include <uxtheme.h> |
31 #endif | 32 #endif |
32 #include <richedit.h> | 33 #include <richedit.h> |
33 | 34 |
34 #define STATICCLASSNAME "STATIC" | 35 #define STATICCLASSNAME TEXT("STATIC") |
35 #define COMBOBOXCLASSNAME "COMBOBOX" | 36 #define COMBOBOXCLASSNAME TEXT("COMBOBOX") |
36 #define LISTBOXCLASSNAME "LISTBOX" | 37 #define LISTBOXCLASSNAME TEXT("LISTBOX") |
37 #define BUTTONCLASSNAME "BUTTON" | 38 #define BUTTONCLASSNAME TEXT("BUTTON") |
38 #define POPUPMENUCLASSNAME "POPUPMENU" | 39 #define POPUPMENUCLASSNAME TEXT("POPUPMENU") |
39 #define EDITCLASSNAME "EDIT" | 40 #define EDITCLASSNAME TEXT("EDIT") |
40 #define FRAMECLASSNAME "FRAME" | 41 #define FRAMECLASSNAME TEXT("FRAME") |
41 #define SCROLLBARCLASSNAME "SCROLLBAR" | 42 #define SCROLLBARCLASSNAME TEXT("SCROLLBAR") |
42 | 43 |
43 #define ClassName "dynamicwindows" | 44 #define ClassName TEXT("dynamicwindows") |
44 #define SplitbarClassName "dwsplitbar" | 45 #define SplitbarClassName TEXT("dwsplitbar") |
45 #define ObjectClassName "dwobjectclass" | 46 #define ObjectClassName TEXT("dwobjectclass") |
46 #define BrowserClassName "dwbrowserclass" | 47 #define BrowserClassName TEXT("dwbrowserclass") |
47 #define ScrollClassName "dwscrollclass" | 48 #define ScrollClassName TEXT("dwscrollclass") |
48 #define StatusbarClassName "dwstatusbar" | 49 #define StatusbarClassName TEXT("dwstatusbar") |
49 #define DefaultFont NULL | 50 #define DefaultFont NULL |
50 | 51 |
51 #ifdef GDIPLUS | 52 #ifdef GDIPLUS |
52 /* GDI+ Headers are not C compatible... so define what we need here instead */ | 53 /* GDI+ Headers are not C compatible... so define what we need here instead */ |
53 struct GdiplusStartupInput | 54 struct GdiplusStartupInput |
432 | 433 |
433 return main(argc, argv); | 434 return main(argc, argv); |
434 } | 435 } |
435 #endif | 436 #endif |
436 | 437 |
438 #ifdef UNICODE | |
437 /* Macro and internal function to convert UTF8 to Unicode wide characters */ | 439 /* Macro and internal function to convert UTF8 to Unicode wide characters */ |
438 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) | 440 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) |
439 LPWSTR _myUTF8toWide(char *utf8string, void *outbuf) | 441 LPWSTR _myUTF8toWide(char *utf8string, void *outbuf) |
440 { | 442 { |
441 LPWSTR retbuf = outbuf; | 443 LPWSTR retbuf = outbuf; |
442 | 444 |
443 if(retbuf) | 445 if(retbuf) |
444 MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, retbuf, MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR)); | 446 MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, retbuf, MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR)); |
445 return retbuf; | 447 return retbuf; |
446 } | 448 } |
449 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL) | |
450 char *_myWideToUTF8(LPWSTR widestring, void *outbuf) | |
451 { | |
452 char *retbuf = outbuf; | |
453 | |
454 if(retbuf) | |
455 WideCharToMultiByte(CP_UTF8, 0, widestring, -1, retbuf, WideCharToMultiByte(CP_UTF8, 0, widestring, -1, NULL, 0, NULL, NULL), NULL, NULL); | |
456 return retbuf; | |
457 } | |
458 /* FIXME: Not sure why this is needed */ | |
459 #ifndef _tstol | |
460 #define _tstol _wtol | |
461 #endif | |
462 #ifndef _tcscpy | |
463 #define _tcscpy wcscpy | |
464 #endif | |
465 #ifndef _sntprintf | |
466 #define _sntprintf _snwprintf | |
467 #endif | |
468 #ifndef _stprintf | |
469 #define _stprintf _swprintf | |
470 #endif | |
471 #ifndef _tcsftime | |
472 #define _tcsftime wcsftime | |
473 #endif | |
474 | |
475 #else | |
476 #define UTF8toWide(a) a | |
477 #define WideToUTF8(a) a | |
478 /* FIXME: Not sure why this is needed */ | |
479 #ifndef _tstol | |
480 #define _tstol atol | |
481 #endif | |
482 #ifndef _tcscpy | |
483 #define _tcscpy strcpy | |
484 #endif | |
485 #ifndef _sntprintf | |
486 #define _sntprintf _snprintf | |
487 #endif | |
488 #ifndef _stprintf | |
489 #define _stprintf sprintf | |
490 #endif | |
491 #ifndef _tcsftime | |
492 #define _tcsftime strftime | |
493 #endif | |
494 | |
495 #endif | |
447 | 496 |
448 DWORD GetDllVersion(LPCTSTR lpszDllName) | 497 DWORD GetDllVersion(LPCTSTR lpszDllName) |
449 { | 498 { |
450 | 499 |
451 HINSTANCE hinstDll; | 500 HINSTANCE hinstDll; |
667 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam) | 716 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam) |
668 { | 717 { |
669 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 718 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
670 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); | 719 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); |
671 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0); | 720 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0); |
672 char tmpbuf[100] = {0}; | 721 TCHAR tmpbuf[100] = {0}; |
673 | 722 |
674 GetClassName(handle, tmpbuf, 99); | 723 GetClassName(handle, tmpbuf, 99); |
675 | 724 |
676 /* Don't try to free memory from an OLE embedded IE */ | 725 /* Don't try to free memory from an OLE embedded IE */ |
677 if(strncmp(tmpbuf, "Internet Explorer_Server", 25) == 0) | 726 if(_tcsncmp(tmpbuf, TEXT("Internet Explorer_Server"), 25) == 0) |
678 return TRUE; | 727 return TRUE; |
679 | 728 |
680 /* Delete font, icon and bitmap GDI objects in use */ | 729 /* Delete font, icon and bitmap GDI objects in use */ |
681 if(oldfont) | 730 if(oldfont) |
682 DeleteObject(oldfont); | 731 DeleteObject(oldfont); |
683 if(oldicon) | 732 if(oldicon) |
684 DeleteObject(oldicon); | 733 DeleteObject(oldicon); |
685 | 734 |
686 if(_strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0) | 735 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0) |
687 { | 736 { |
688 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); | 737 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); |
689 | 738 |
690 if(oldbitmap) | 739 if(oldbitmap) |
691 DeleteObject(oldbitmap); | 740 DeleteObject(oldbitmap); |
692 } | 741 } |
693 if(_strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0) | 742 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0) |
694 { | 743 { |
695 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); | 744 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); |
696 | 745 |
697 if(oldbitmap) | 746 if(oldbitmap) |
698 DeleteObject(oldbitmap); | 747 DeleteObject(oldbitmap); |
699 } | 748 } |
700 else if(_strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1)==0) | 749 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==0) |
701 { | 750 { |
702 Box *box = (Box *)thiscinfo; | 751 Box *box = (Box *)thiscinfo; |
703 | 752 |
704 if(box && box->count && box->items) | 753 if(box && box->count && box->items) |
705 free(box->items); | 754 free(box->items); |
706 } | 755 } |
707 else if(_strnicmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) | 756 else if(_tcsnicmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0) |
708 { | 757 { |
709 void *data = dw_window_get_data(handle, "_dw_percent"); | 758 void *data = dw_window_get_data(handle, "_dw_percent"); |
710 | 759 |
711 if(data) | 760 if(data) |
712 free(data); | 761 free(data); |
713 } | 762 } |
714 else if(_strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW)+1)==0) | 763 else if(_tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)==0) |
715 { | 764 { |
716 dw_tree_clear(handle); | 765 dw_tree_clear(handle); |
717 } | 766 } |
718 else if(_strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL)+1)==0) /* Notebook */ | 767 else if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL)+1)==0) /* Notebook */ |
719 { | 768 { |
720 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array"); | 769 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array"); |
721 | 770 |
722 if(array) | 771 if(array) |
723 { | 772 { |
734 } | 783 } |
735 } | 784 } |
736 free(array); | 785 free(array); |
737 } | 786 } |
738 } | 787 } |
739 else if(_strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0) | 788 else if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0) |
740 { | 789 { |
741 /* for spinbuttons, we need to get the spinbutton's "buddy", the text window associated and destroy it */ | 790 /* for spinbuttons, we need to get the spinbutton's "buddy", the text window associated and destroy it */ |
742 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 791 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
743 | 792 |
744 if(cinfo && cinfo->buddy) | 793 if(cinfo && cinfo->buddy) |
815 /* This function returns 1 if the window (widget) handle | 864 /* This function returns 1 if the window (widget) handle |
816 * passed to it is a valid window that can gain input focus. | 865 * passed to it is a valid window that can gain input focus. |
817 */ | 866 */ |
818 int _validate_focus(HWND handle) | 867 int _validate_focus(HWND handle) |
819 { | 868 { |
820 char tmpbuf[100] = {0}; | 869 TCHAR tmpbuf[100] = {0}; |
821 | 870 |
822 if(!handle) | 871 if(!handle) |
823 return 0; | 872 return 0; |
824 | 873 |
825 if(!IsWindowEnabled(handle)) | 874 if(!IsWindowEnabled(handle)) |
828 GetClassName(handle, tmpbuf, 99); | 877 GetClassName(handle, tmpbuf, 99); |
829 | 878 |
830 /* These are the window classes which can | 879 /* These are the window classes which can |
831 * obtain input focus. | 880 * obtain input focus. |
832 */ | 881 */ |
833 if(_strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME)+1)==0 || /* Entryfield */ | 882 if(_tcsnicmp(tmpbuf, EDITCLASSNAME, _tcslen(EDITCLASSNAME)+1)==0 || /* Entryfield */ |
834 _strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0 || /* Button */ | 883 _tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0 || /* Button */ |
835 _strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0 || /* Combobox */ | 884 _tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0 || /* Combobox */ |
836 _strnicmp(tmpbuf, LISTBOXCLASSNAME, strlen(LISTBOXCLASSNAME)+1)==0 || /* List box */ | 885 _tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1)==0 || /* List box */ |
837 _strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0 || /* Spinbutton */ | 886 _tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0 || /* Spinbutton */ |
838 _strnicmp(tmpbuf, TRACKBAR_CLASS, strlen(TRACKBAR_CLASS)+1)==0 || /* Slider */ | 887 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1)==0 || /* Slider */ |
839 _strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW)+1)== 0 || /* Container */ | 888 _tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0 || /* Container */ |
840 _strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW)+1)== 0) /* Tree */ | 889 _tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)== 0) /* Tree */ |
841 return 1; | 890 return 1; |
842 return 0; | 891 return 0; |
843 } | 892 } |
844 | 893 |
845 HWND _normalize_handle(HWND handle) | 894 HWND _normalize_handle(HWND handle) |
846 { | 895 { |
847 char tmpbuf[100] = {0}; | 896 TCHAR tmpbuf[100] = {0}; |
848 | 897 |
849 GetClassName(handle, tmpbuf, 99); | 898 GetClassName(handle, tmpbuf, 99); |
850 if(_strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) /* Spinner */ | 899 if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS))==0) /* Spinner */ |
851 { | 900 { |
852 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 901 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
853 | 902 |
854 if(cinfo && cinfo->buddy) | 903 if(cinfo && cinfo->buddy) |
855 return cinfo->buddy; | 904 return cinfo->buddy; |
856 } | 905 } |
857 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) /* Combobox */ | 906 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME))==0) /* Combobox */ |
858 { | 907 { |
859 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 908 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
860 | 909 |
861 if(cinfo && cinfo->buddy) | 910 if(cinfo && cinfo->buddy) |
862 return cinfo->buddy; | 911 return cinfo->buddy; |
937 | 986 |
938 lasthwnd = _normalize_handle(box->items[z].hwnd); | 987 lasthwnd = _normalize_handle(box->items[z].hwnd); |
939 } | 988 } |
940 else | 989 else |
941 { | 990 { |
942 char tmpbuf[100] = {0}; | 991 TCHAR tmpbuf[100] = {0}; |
943 | 992 |
944 GetClassName(box->items[z].hwnd, tmpbuf, 99); | 993 GetClassName(box->items[z].hwnd, tmpbuf, 99); |
945 | 994 |
946 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) | 995 if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0) |
947 { | 996 { |
948 /* Then try the bottom or right box */ | 997 /* Then try the bottom or right box */ |
949 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright"); | 998 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright"); |
950 | 999 |
951 if(mybox) | 1000 if(mybox) |
965 | 1014 |
966 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) | 1015 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) |
967 return 1; | 1016 return 1; |
968 } | 1017 } |
969 } | 1018 } |
970 else if(_strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */ | 1019 else if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) /* Notebook */ |
971 { | 1020 { |
972 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array"); | 1021 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array"); |
973 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); | 1022 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); |
974 | 1023 |
975 if(pageid > -1 && array && array[pageid]) | 1024 if(pageid > -1 && array && array[pageid]) |
983 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem)) | 1032 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem)) |
984 return 1; | 1033 return 1; |
985 } | 1034 } |
986 } | 1035 } |
987 } | 1036 } |
988 else if(_strnicmp(tmpbuf, ScrollClassName, strlen(ScrollClassName))==0) /* Scroll Box */ | 1037 else if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName))==0) /* Scroll Box */ |
989 { | 1038 { |
990 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); | 1039 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); |
991 Box *scrollbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA); | 1040 Box *scrollbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA); |
992 | 1041 |
993 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, defaultitem)) | 1042 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, defaultitem)) |
1072 | 1121 |
1073 lasthwnd = _normalize_handle(box->items[z].hwnd); | 1122 lasthwnd = _normalize_handle(box->items[z].hwnd); |
1074 } | 1123 } |
1075 else | 1124 else |
1076 { | 1125 { |
1077 char tmpbuf[100] = {0}; | 1126 TCHAR tmpbuf[100] = {0}; |
1078 | 1127 |
1079 GetClassName(box->items[z].hwnd, tmpbuf, 99); | 1128 GetClassName(box->items[z].hwnd, tmpbuf, 99); |
1080 | 1129 |
1081 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) | 1130 if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0) |
1082 { | 1131 { |
1083 /* Try the top or left box */ | 1132 /* Try the top or left box */ |
1084 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft"); | 1133 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft"); |
1085 | 1134 |
1086 if(mybox) | 1135 if(mybox) |
1100 | 1149 |
1101 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) | 1150 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) |
1102 return 1; | 1151 return 1; |
1103 } | 1152 } |
1104 } | 1153 } |
1105 else if(_strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */ | 1154 else if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) /* Notebook */ |
1106 { | 1155 { |
1107 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array"); | 1156 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array"); |
1108 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); | 1157 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); |
1109 | 1158 |
1110 if(pageid > -1 && array && array[pageid]) | 1159 if(pageid > -1 && array && array[pageid]) |
1118 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem)) | 1167 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem)) |
1119 return 1; | 1168 return 1; |
1120 } | 1169 } |
1121 } | 1170 } |
1122 } | 1171 } |
1123 else if(_strnicmp(tmpbuf, ScrollClassName, strlen(ScrollClassName))==0) /* Scroll Box */ | 1172 else if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName))==0) /* Scroll Box */ |
1124 { | 1173 { |
1125 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); | 1174 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA); |
1126 Box *scrollbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA); | 1175 Box *scrollbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA); |
1127 | 1176 |
1128 if(scrollbox && _focus_check_box_back(scrollbox, handle, start == 3 ? 3 : 0, defaultitem)) | 1177 if(scrollbox && _focus_check_box_back(scrollbox, handle, start == 3 ? 3 : 0, defaultitem)) |
1138 * layout and moves the current focus to it. | 1187 * layout and moves the current focus to it. |
1139 */ | 1188 */ |
1140 void _initial_focus(HWND handle) | 1189 void _initial_focus(HWND handle) |
1141 { | 1190 { |
1142 Box *thisbox; | 1191 Box *thisbox; |
1143 char tmpbuf[100] = {0}; | 1192 TCHAR tmpbuf[100] = {0}; |
1144 | 1193 |
1145 if(!handle) | 1194 if(!handle) |
1146 return; | 1195 return; |
1147 | 1196 |
1148 GetClassName(handle, tmpbuf, 99); | 1197 GetClassName(handle, tmpbuf, 99); |
1149 | 1198 |
1150 if(_strnicmp(tmpbuf, ClassName, strlen(ClassName)+1)!=0) | 1199 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)!=0) |
1151 return; | 1200 return; |
1152 | 1201 |
1153 | 1202 |
1154 if(handle) | 1203 if(handle) |
1155 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); | 1204 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); |
1172 return 0; | 1221 return 0; |
1173 lastbox = box; | 1222 lastbox = box; |
1174 } | 1223 } |
1175 if(lastbox) | 1224 if(lastbox) |
1176 { | 1225 { |
1177 char tmpbuf[100] = {0}; | 1226 TCHAR tmpbuf[100] = {0}; |
1178 | 1227 |
1179 GetClassName(lastbox, tmpbuf, 99); | 1228 GetClassName(lastbox, tmpbuf, 99); |
1180 | 1229 |
1181 if(strncmp(tmpbuf, ClassName, strlen(ClassName)+1)==0) | 1230 if(_tcsncmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0) |
1182 return lastbox; | 1231 return lastbox; |
1183 } | 1232 } |
1184 return 0; | 1233 return 0; |
1185 } | 1234 } |
1186 | 1235 |
1420 /* If the calculated size is valid... */ | 1469 /* If the calculated size is valid... */ |
1421 if(width > 0 && height > 0) | 1470 if(width > 0 && height > 0) |
1422 { | 1471 { |
1423 int pad = thisbox->items[z].pad; | 1472 int pad = thisbox->items[z].pad; |
1424 HWND handle = thisbox->items[z].hwnd; | 1473 HWND handle = thisbox->items[z].hwnd; |
1425 char tmpbuf[100] = {0}; | 1474 TCHAR tmpbuf[100] = {0}; |
1426 | 1475 |
1427 GetClassName(handle, tmpbuf, 99); | 1476 GetClassName(handle, tmpbuf, 99); |
1428 | 1477 |
1429 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 1478 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
1430 { | 1479 { |
1431 /* Handle special case Combobox */ | 1480 /* Handle special case Combobox */ |
1432 MoveWindow(handle, currentx + pad, currenty + pad, | 1481 MoveWindow(handle, currentx + pad, currenty + pad, |
1433 width, height + 400, FALSE); | 1482 width, height + 400, FALSE); |
1434 } | 1483 } |
1435 else if(_strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0) | 1484 else if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0) |
1436 { | 1485 { |
1437 /* Handle special case Spinbutton */ | 1486 /* Handle special case Spinbutton */ |
1438 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 1487 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
1439 | 1488 |
1440 MoveWindow(handle, currentx + pad + (width - 20), currenty + pad, | 1489 MoveWindow(handle, currentx + pad + (width - 20), currenty + pad, |
1444 { | 1493 { |
1445 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad, | 1494 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad, |
1446 width - 20, height, FALSE); | 1495 width - 20, height, FALSE); |
1447 } | 1496 } |
1448 } | 1497 } |
1449 else if(strncmp(tmpbuf, ScrollClassName, strlen(ScrollClassName)+1)==0) | 1498 else if(_tcsncmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName)+1)==0) |
1450 { | 1499 { |
1451 /* Handle special case of scrollbox */ | 1500 /* Handle special case of scrollbox */ |
1452 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 1501 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
1453 int cx, cy, depth = 0; | 1502 int cx, cy, depth = 0; |
1454 Box *thisbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA); | 1503 Box *thisbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA); |
1508 SetScrollInfo(handle, SB_VERT, &vsi, TRUE); | 1557 SetScrollInfo(handle, SB_VERT, &vsi, TRUE); |
1509 | 1558 |
1510 /* Layout the content of the scrollbox */ | 1559 /* Layout the content of the scrollbox */ |
1511 _do_resize(thisbox, cx, cy); | 1560 _do_resize(thisbox, cx, cy); |
1512 } | 1561 } |
1513 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) | 1562 else if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0) |
1514 { | 1563 { |
1515 /* Then try the bottom or right box */ | 1564 /* Then try the bottom or right box */ |
1516 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); | 1565 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); |
1517 int type = (int)dw_window_get_data(handle, "_dw_type"); | 1566 int type = (int)dw_window_get_data(handle, "_dw_type"); |
1518 | 1567 |
1520 width, height, FALSE); | 1569 width, height, FALSE); |
1521 | 1570 |
1522 if(percent && width > 0 && height > 0) | 1571 if(percent && width > 0 && height > 0) |
1523 _handle_splitbar_resize(handle, *percent, type, width, height); | 1572 _handle_splitbar_resize(handle, *percent, type, width, height); |
1524 } | 1573 } |
1525 else if(_strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0) | 1574 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0) |
1526 { | 1575 { |
1527 /* Handle special case Vertically Center static text */ | 1576 /* Handle special case Vertically Center static text */ |
1528 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 1577 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
1529 | 1578 |
1530 if(cinfo && cinfo->vcenter) | 1579 if(cinfo && cinfo->vcenter) |
1531 { | 1580 { |
1532 /* We are centered so calculate a new position */ | 1581 /* We are centered so calculate a new position */ |
1533 char tmpbuf[1024] = {0}; | 1582 TCHAR tmpbuf[1024] = {0}; |
1534 int textheight, diff, total = height; | 1583 int textheight, diff, total = height; |
1535 | 1584 |
1536 GetWindowText(handle, tmpbuf, 1023); | 1585 GetWindowText(handle, tmpbuf, 1023); |
1537 | 1586 |
1538 /* Figure out how big the text is */ | 1587 /* Figure out how big the text is */ |
1539 dw_font_text_extents_get(handle, 0, tmpbuf, 0, &textheight); | 1588 dw_font_text_extents_get(handle, 0, WideToUTF8(tmpbuf), 0, &textheight); |
1540 | 1589 |
1541 diff = (total - textheight) / 2; | 1590 diff = (total - textheight) / 2; |
1542 | 1591 |
1543 MoveWindow(handle, currentx + pad, currenty + pad + diff, | 1592 MoveWindow(handle, currentx + pad, currenty + pad + diff, |
1544 width, height - diff, FALSE); | 1593 width, height - diff, FALSE); |
1577 } | 1626 } |
1578 } | 1627 } |
1579 } | 1628 } |
1580 | 1629 |
1581 /* Notebook dialog requires additional processing */ | 1630 /* Notebook dialog requires additional processing */ |
1582 if(strncmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) | 1631 if(_tcsncmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) |
1583 { | 1632 { |
1584 RECT rect; | 1633 RECT rect; |
1585 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array"); | 1634 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array"); |
1586 int pageid = TabCtrl_GetCurSel(handle); | 1635 int pageid = TabCtrl_GetCurSel(handle); |
1587 | 1636 |
1593 rect.right - rect.left, rect.bottom-rect.top, FALSE); | 1642 rect.right - rect.left, rect.bottom-rect.top, FALSE); |
1594 dw_window_redraw(array[pageid]->hwnd); | 1643 dw_window_redraw(array[pageid]->hwnd); |
1595 } | 1644 } |
1596 } | 1645 } |
1597 /* So does the List View... handle delayed cursoring */ | 1646 /* So does the List View... handle delayed cursoring */ |
1598 if(_strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW)+1)==0 && width > 10 && height > 10) | 1647 if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)==0 && width > 10 && height > 10) |
1599 { | 1648 { |
1600 int index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_cursor")); | 1649 int index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_cursor")); |
1601 | 1650 |
1602 if(index > 0) | 1651 if(index > 0) |
1603 ListView_EnsureVisible(handle, index, TRUE); | 1652 ListView_EnsureVisible(handle, index, TRUE); |
1943 tmp->message == NM_RCLICK || | 1992 tmp->message == NM_RCLICK || |
1944 tmp->message == TVN_ITEMEXPANDED) | 1993 tmp->message == TVN_ITEMEXPANDED) |
1945 { | 1994 { |
1946 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2; | 1995 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2; |
1947 NMLISTVIEW FAR *lem=(NMLISTVIEW FAR *)mp2; | 1996 NMLISTVIEW FAR *lem=(NMLISTVIEW FAR *)mp2; |
1948 char tmpbuf[100] = {0}; | 1997 TCHAR tmpbuf[100] = {0}; |
1949 | 1998 |
1950 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99); | 1999 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99); |
1951 | 2000 |
1952 if(_strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW))==0) | 2001 if(_tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW))==0) |
1953 { | 2002 { |
1954 if(tem->hdr.code == TVN_SELCHANGED && tmp->message == TVN_SELCHANGED) | 2003 if(tem->hdr.code == TVN_SELCHANGED && tmp->message == TVN_SELCHANGED) |
1955 { | 2004 { |
1956 if(tmp->window == tem->hdr.hwndFrom && !dw_window_get_data(tmp->window, "_dw_select_item")) | 2005 if(tmp->window == tem->hdr.hwndFrom && !dw_window_get_data(tmp->window, "_dw_select_item")) |
1957 { | 2006 { |
2015 containercontextfunc(tmp->window, ptrs ? (char *)ptrs[0] : NULL, x, y, tmp->data, ptrs ? ptrs[1] : NULL); | 2064 containercontextfunc(tmp->window, ptrs ? (char *)ptrs[0] : NULL, x, y, tmp->data, ptrs ? ptrs[1] : NULL); |
2016 tmp = NULL; | 2065 tmp = NULL; |
2017 } | 2066 } |
2018 } | 2067 } |
2019 } | 2068 } |
2020 else if(_strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW)+1)==0) | 2069 else if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)==0) |
2021 { | 2070 { |
2022 if((lem->hdr.code == LVN_ITEMCHANGED && (lem->uChanged & LVIF_STATE)) && tmp->message == TVN_SELCHANGED) | 2071 if((lem->hdr.code == LVN_ITEMCHANGED && (lem->uChanged & LVIF_STATE)) && tmp->message == TVN_SELCHANGED) |
2023 { | 2072 { |
2024 if(tmp->window == tem->hdr.hwndFrom) | 2073 if(tmp->window == tem->hdr.hwndFrom) |
2025 { | 2074 { |
2115 } | 2164 } |
2116 break; | 2165 break; |
2117 case WM_HSCROLL: | 2166 case WM_HSCROLL: |
2118 case WM_VSCROLL: | 2167 case WM_VSCROLL: |
2119 { | 2168 { |
2120 char tmpbuf[100] = {0}; | 2169 TCHAR tmpbuf[100] = {0}; |
2121 HWND handle = (HWND)mp2; | 2170 HWND handle = (HWND)mp2; |
2122 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction; | 2171 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction; |
2123 | 2172 |
2124 if(!GetClassName(handle, tmpbuf, 99)) | 2173 if(!GetClassName(handle, tmpbuf, 99)) |
2125 { | 2174 { |
2126 GetClassName(hWnd, tmpbuf, 99); | 2175 GetClassName(hWnd, tmpbuf, 99); |
2127 } | 2176 } |
2128 | 2177 |
2129 if (_strnicmp(tmpbuf, TRACKBAR_CLASS, strlen(TRACKBAR_CLASS)+1)==0) | 2178 if (_tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1)==0) |
2130 { | 2179 { |
2131 | 2180 |
2132 if (handle == tmp->window) | 2181 if (handle == tmp->window) |
2133 { | 2182 { |
2134 int value = (int)SendMessage(handle, TBM_GETPOS, 0, 0); | 2183 int value = (int)SendMessage(handle, TBM_GETPOS, 0, 0); |
2140 else | 2189 else |
2141 result = valuechangefunc(tmp->window, value, tmp->data); | 2190 result = valuechangefunc(tmp->window, value, tmp->data); |
2142 tmp = NULL; | 2191 tmp = NULL; |
2143 } | 2192 } |
2144 } | 2193 } |
2145 else if(_strnicmp(tmpbuf, SCROLLBARCLASSNAME, strlen(SCROLLBARCLASSNAME)+1)==0) | 2194 else if(_tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1)==0) |
2146 { | 2195 { |
2147 if(handle == tmp->window) | 2196 if(handle == tmp->window) |
2148 { | 2197 { |
2149 int bar = (origmsg == WM_HSCROLL) ? SB_HORZ : SB_VERT; | 2198 int bar = (origmsg == WM_HSCROLL) ? SB_HORZ : SB_VERT; |
2150 int value = _HandleScroller(handle, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); | 2199 int value = _HandleScroller(handle, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); |
2286 if(value > -1) | 2335 if(value > -1) |
2287 dw_scrollbar_set_pos(handle, value); | 2336 dw_scrollbar_set_pos(handle, value); |
2288 } | 2337 } |
2289 else | 2338 else |
2290 { | 2339 { |
2291 char tmpbuf[100] = {0}; | 2340 TCHAR tmpbuf[100] = {0}; |
2292 | 2341 |
2293 GetClassName( hWnd, tmpbuf, 99 ); | 2342 GetClassName( hWnd, tmpbuf, 99 ); |
2294 if ( _strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1 ) == 0 ) | 2343 if ( _tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1 ) == 0 ) |
2295 { | 2344 { |
2296 _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); | 2345 _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); |
2297 } | 2346 } |
2298 } | 2347 } |
2299 } | 2348 } |
2578 break; | 2627 break; |
2579 case WM_USER+10: | 2628 case WM_USER+10: |
2580 { | 2629 { |
2581 if(cinfo->buddy) | 2630 if(cinfo->buddy) |
2582 { | 2631 { |
2583 char tempbuf[100] = ""; | 2632 TCHAR tempbuf[100] = { 0 }; |
2584 long position; | 2633 long position; |
2585 | 2634 |
2586 GetWindowText(cinfo->buddy, tempbuf, 99); | 2635 GetWindowText(cinfo->buddy, tempbuf, 99); |
2587 | 2636 |
2588 position = atol(tempbuf); | 2637 position = _tstol(tempbuf); |
2589 | 2638 |
2590 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position); | 2639 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position); |
2591 } | 2640 } |
2592 } | 2641 } |
2593 break; | 2642 break; |
2599 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); | 2648 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); |
2600 } | 2649 } |
2601 | 2650 |
2602 void _click_default(HWND handle) | 2651 void _click_default(HWND handle) |
2603 { | 2652 { |
2604 char tmpbuf[100] = {0}; | 2653 TCHAR tmpbuf[100] = {0}; |
2605 | 2654 |
2606 GetClassName(handle, tmpbuf, 99); | 2655 GetClassName(handle, tmpbuf, 99); |
2607 | 2656 |
2608 /* These are the window classes which can | 2657 /* These are the window classes which can |
2609 * obtain input focus. | 2658 * obtain input focus. |
2610 */ | 2659 */ |
2611 if (_strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME))==0) | 2660 if (_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0) |
2612 { | 2661 { |
2613 /* Generate click on default item */ | 2662 /* Generate click on default item */ |
2614 SignalHandler *tmp = Root; | 2663 SignalHandler *tmp = Root; |
2615 | 2664 |
2616 /* Find any callbacks for this function */ | 2665 /* Find any callbacks for this function */ |
2636 | 2685 |
2637 /* Subclass function that will handle setting colors on controls */ | 2686 /* Subclass function that will handle setting colors on controls */ |
2638 LRESULT CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | 2687 LRESULT CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) |
2639 { | 2688 { |
2640 ColorInfo *cinfo; | 2689 ColorInfo *cinfo; |
2641 char tmpbuf[100] = {0}; | 2690 TCHAR tmpbuf[100] = {0}; |
2642 WNDPROC pOldProc = 0; | 2691 WNDPROC pOldProc = 0; |
2643 LRESULT ret = -1; | 2692 LRESULT ret = -1; |
2644 | 2693 |
2645 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); | 2694 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); |
2646 | 2695 |
2647 GetClassName(hWnd, tmpbuf, 99); | 2696 GetClassName(hWnd, tmpbuf, 99); |
2648 if(strcmp(tmpbuf, FRAMECLASSNAME) == 0) | 2697 if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0) |
2649 cinfo = &(((Box *)cinfo)->cinfo); | 2698 cinfo = &(((Box *)cinfo)->cinfo); |
2650 | 2699 |
2651 if ( msg == WM_MOUSEMOVE || msg == WM_USER+2 ) | 2700 if ( msg == WM_MOUSEMOVE || msg == WM_USER+2 ) |
2652 ret = _wndproc(hWnd, msg, mp1, mp2); | 2701 ret = _wndproc(hWnd, msg, mp1, mp2); |
2653 | 2702 |
2769 { | 2818 { |
2770 long val; | 2819 long val; |
2771 | 2820 |
2772 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0); | 2821 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0); |
2773 | 2822 |
2774 sprintf(tmpbuf, "%ld", val); | 2823 _stprintf(tmpbuf, TEXT("%ld"), val); |
2775 SetWindowText(hWnd, tmpbuf); | 2824 SetWindowText(hWnd, tmpbuf); |
2776 } | 2825 } |
2777 } | 2826 } |
2778 break; | 2827 break; |
2779 case WM_CTLCOLORSTATIC: | 2828 case WM_CTLCOLORSTATIC: |
3325 { | 3374 { |
3326 HDC hdcPaint; | 3375 HDC hdcPaint; |
3327 PAINTSTRUCT ps; | 3376 PAINTSTRUCT ps; |
3328 RECT rc; | 3377 RECT rc; |
3329 unsigned long cx, cy; | 3378 unsigned long cx, cy; |
3330 char tempbuf[1025] = { 0 }; | 3379 TCHAR tempbuf[1025] = { 0 }; |
3331 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA); | 3380 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA); |
3332 HFONT hfont = _acquire_font(hwnd, cinfo ? cinfo->fontname : NULL); | 3381 HFONT hfont = _acquire_font(hwnd, cinfo ? cinfo->fontname : NULL); |
3333 HFONT oldfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0); | 3382 HFONT oldfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0); |
3334 | 3383 |
3335 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy); | 3384 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy); |
3667 */ | 3716 */ |
3668 ti.cbSize = sizeof(TOOLINFO); | 3717 ti.cbSize = sizeof(TOOLINFO); |
3669 ti.uFlags = TTF_SUBCLASS; | 3718 ti.uFlags = TTF_SUBCLASS; |
3670 ti.hwnd = handle; | 3719 ti.hwnd = handle; |
3671 ti.hinst = DWInstance; | 3720 ti.hinst = DWInstance; |
3672 ti.lpszText = text; | 3721 ti.lpszText = UTF8toWide(text); |
3673 ti.rect.right = ti.rect.bottom = 2000; | 3722 ti.rect.right = ti.rect.bottom = 2000; |
3674 | 3723 |
3675 /* Associate the tooltip with the "tool" window. */ | 3724 /* Associate the tooltip with the "tool" window. */ |
3676 SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); | 3725 SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); |
3677 } | 3726 } |
3793 if(pos) | 3842 if(pos) |
3794 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); | 3843 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); |
3795 } | 3844 } |
3796 /* If that failed... just get the current directory */ | 3845 /* If that failed... just get the current directory */ |
3797 if(!_dw_exec_dir[0]) | 3846 if(!_dw_exec_dir[0]) |
3798 GetCurrentDirectory(MAX_PATH, _dw_exec_dir); | 3847 GetCurrentDirectoryA(MAX_PATH, _dw_exec_dir); |
3799 | 3848 |
3800 /* Initialize our thread local storage */ | 3849 /* Initialize our thread local storage */ |
3801 _foreground = TlsAlloc(); | 3850 _foreground = TlsAlloc(); |
3802 _background = TlsAlloc(); | 3851 _background = TlsAlloc(); |
3803 _hPen = TlsAlloc(); | 3852 _hPen = TlsAlloc(); |
3955 GdiplusStartup(&gdiplusToken, &si, NULL); | 4004 GdiplusStartup(&gdiplusToken, &si, NULL); |
3956 #endif | 4005 #endif |
3957 | 4006 |
3958 #ifdef AEROGLASS | 4007 #ifdef AEROGLASS |
3959 /* Attempt to load the Desktop Window Manager and Theme library */ | 4008 /* Attempt to load the Desktop Window Manager and Theme library */ |
3960 if((hdwm = LoadLibrary("dwmapi")) && (huxtheme = LoadLibrary("uxtheme"))) | 4009 if((hdwm = LoadLibrary(TEXT("dwmapi"))) && (huxtheme = LoadLibrary(TEXT("uxtheme")))) |
3961 { | 4010 { |
3962 _DwmExtendFrameIntoClientArea = (HRESULT (WINAPI *)(HWND, const MARGINS *))GetProcAddress(hdwm, "DwmExtendFrameIntoClientArea"); | 4011 _DwmExtendFrameIntoClientArea = (HRESULT (WINAPI *)(HWND, const MARGINS *))GetProcAddress(hdwm, "DwmExtendFrameIntoClientArea"); |
3963 if((_DwmIsCompositionEnabled = (HRESULT (WINAPI *)(BOOL *))GetProcAddress(hdwm, "DwmIsCompositionEnabled"))) | 4012 if((_DwmIsCompositionEnabled = (HRESULT (WINAPI *)(BOOL *))GetProcAddress(hdwm, "DwmIsCompositionEnabled"))) |
3964 _DwmIsCompositionEnabled(&_dw_composition); | 4013 _DwmIsCompositionEnabled(&_dw_composition); |
3965 _OpenThemeData = (HTHEME (WINAPI *)(HWND, LPCWSTR))GetProcAddress(huxtheme, "OpenThemeData"); | 4014 _OpenThemeData = (HTHEME (WINAPI *)(HWND, LPCWSTR))GetProcAddress(huxtheme, "OpenThemeData"); |
4156 | 4205 |
4157 va_start(args, format); | 4206 va_start(args, format); |
4158 vsnprintf(outbuf, 1024, format, args); | 4207 vsnprintf(outbuf, 1024, format, args); |
4159 va_end(args); | 4208 va_end(args); |
4160 | 4209 |
4161 OutputDebugString(outbuf); | 4210 OutputDebugString(UTF8toWide(outbuf)); |
4162 } | 4211 } |
4163 | 4212 |
4164 /* | 4213 /* |
4165 * Displays a Message Box with given text and title.. | 4214 * Displays a Message Box with given text and title.. |
4166 * Parameters: | 4215 * Parameters: |
4176 | 4225 |
4177 va_start(args, format); | 4226 va_start(args, format); |
4178 vsnprintf(outbuf, 1024, format, args); | 4227 vsnprintf(outbuf, 1024, format, args); |
4179 va_end(args); | 4228 va_end(args); |
4180 | 4229 |
4181 rc = MessageBox(HWND_DESKTOP, outbuf, title, flags); | 4230 rc = MessageBox(HWND_DESKTOP, UTF8toWide(outbuf), UTF8toWide(title), flags); |
4182 if(rc == IDOK) | 4231 if(rc == IDOK) |
4183 return DW_MB_RETURN_OK; | 4232 return DW_MB_RETURN_OK; |
4184 else if(rc == IDYES) | 4233 else if(rc == IDYES) |
4185 return DW_MB_RETURN_YES; | 4234 return DW_MB_RETURN_YES; |
4186 else if(rc == IDNO) | 4235 else if(rc == IDNO) |
4407 myFontName = _strdup(&fontname[z+1]); | 4456 myFontName = _strdup(&fontname[z+1]); |
4408 if(Italic) | 4457 if(Italic) |
4409 myFontName[Italic] = 0; | 4458 myFontName[Italic] = 0; |
4410 if(Bold) | 4459 if(Bold) |
4411 myFontName[Bold] = 0; | 4460 myFontName[Bold] = 0; |
4412 strncpy(lf.lfFaceName, myFontName, sizeof(lf.lfFaceName)-1); | 4461 _tcsncpy(lf.lfFaceName, UTF8toWide(myFontName), sizeof(lf.lfFaceName)-1); |
4413 free(myFontName); | 4462 free(myFontName); |
4414 return lf; | 4463 return lf; |
4415 } | 4464 } |
4416 | 4465 |
4417 /* Create a duplicate of an existing font handle | 4466 /* Create a duplicate of an existing font handle |
4507 * Buttons/Bitmaps: Size of text or image and border. | 4556 * Buttons/Bitmaps: Size of text or image and border. |
4508 */ | 4557 */ |
4509 void _control_size(HWND handle, int *width, int *height) | 4558 void _control_size(HWND handle, int *width, int *height) |
4510 { | 4559 { |
4511 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0; | 4560 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0; |
4512 char tmpbuf[100] = {0}, *buf = dw_window_get_text(handle); | 4561 char *buf = dw_window_get_text(handle); |
4562 TCHAR tmpbuf[100] = {0}; | |
4513 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | 4563 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
4514 HBITMAP hbm = 0; | 4564 HBITMAP hbm = 0; |
4515 | 4565 |
4516 GetClassName(handle, tmpbuf, 99); | 4566 GetClassName(handle, tmpbuf, 99); |
4517 | 4567 |
4524 dw_font_text_extents_get(handle, NULL, buf, &thiswidth, &thisheight); | 4574 dw_font_text_extents_get(handle, NULL, buf, &thiswidth, &thisheight); |
4525 dw_free(buf); | 4575 dw_free(buf); |
4526 } | 4576 } |
4527 | 4577 |
4528 /* Attempt to get bitmap from classes that can have them */ | 4578 /* Attempt to get bitmap from classes that can have them */ |
4529 if(_strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1) == 0) | 4579 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0) |
4530 hbm = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); | 4580 hbm = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); |
4531 if(_strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1) == 0) | 4581 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0) |
4532 hbm = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); | 4582 hbm = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); |
4533 | 4583 |
4534 /* If we got an image... set the sizes appropriately */ | 4584 /* If we got an image... set the sizes appropriately */ |
4535 if(hbm) | 4585 if(hbm) |
4536 { | 4586 { |
4540 thiswidth = bmi.bmWidth; | 4590 thiswidth = bmi.bmWidth; |
4541 thisheight = bmi.bmHeight; | 4591 thisheight = bmi.bmHeight; |
4542 } | 4592 } |
4543 | 4593 |
4544 /* Combobox */ | 4594 /* Combobox */ |
4545 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1) == 0) | 4595 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1) == 0) |
4546 { | 4596 { |
4547 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); | 4597 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); |
4548 thiswidth = 150; | 4598 thiswidth = 150; |
4549 extraheight = 4; | 4599 extraheight = 4; |
4550 if(thisheight < 18) | 4600 if(thisheight < 18) |
4551 thisheight = 18; | 4601 thisheight = 18; |
4552 } | 4602 } |
4553 /* Ranged: Percent, Slider, Scrollbar */ | 4603 /* Ranged: Percent, Slider, Scrollbar */ |
4554 else if(_strnicmp(tmpbuf, PROGRESS_CLASS, strlen(PROGRESS_CLASS)+1) == 0 || | 4604 else if(_tcsnicmp(tmpbuf, PROGRESS_CLASS, _tcslen(PROGRESS_CLASS)+1) == 0 || |
4555 _strnicmp(tmpbuf, TRACKBAR_CLASS, strlen(TRACKBAR_CLASS)+1) == 0 || | 4605 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1) == 0 || |
4556 _strnicmp(tmpbuf, SCROLLBARCLASSNAME, strlen(SCROLLBARCLASSNAME)+1) == 0) | 4606 _tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1) == 0) |
4557 { | 4607 { |
4558 if(_strnicmp(tmpbuf, SCROLLBARCLASSNAME, strlen(SCROLLBARCLASSNAME)+1) == 0 && | 4608 if(_tcsnicmp(tmpbuf, SCROLLBARCLASSNAME, _tcslen(SCROLLBARCLASSNAME)+1) == 0 && |
4559 GetWindowLong(handle, GWL_STYLE) & SBS_VERT) | 4609 GetWindowLong(handle, GWL_STYLE) & SBS_VERT) |
4560 { | 4610 { |
4561 /* Vertical */ | 4611 /* Vertical */ |
4562 thiswidth = GetSystemMetrics(SM_CXVSCROLL); | 4612 thiswidth = GetSystemMetrics(SM_CXVSCROLL); |
4563 thisheight = 100; | 4613 thisheight = 100; |
4568 thiswidth = 100; | 4618 thiswidth = 100; |
4569 thisheight = GetSystemMetrics(SM_CYHSCROLL); | 4619 thisheight = GetSystemMetrics(SM_CYHSCROLL); |
4570 } | 4620 } |
4571 } | 4621 } |
4572 /* Spinbuttons */ | 4622 /* Spinbuttons */ |
4573 else if(_strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1) == 0) | 4623 else if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1) == 0) |
4574 { | 4624 { |
4575 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); | 4625 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); |
4576 thiswidth = 50; | 4626 thiswidth = 50; |
4577 extraheight = 6; | 4627 extraheight = 6; |
4578 } | 4628 } |
4579 /* Listbox */ | 4629 /* Listbox */ |
4580 else if(_strnicmp(tmpbuf, LISTBOXCLASSNAME, strlen(LISTBOXCLASSNAME)+1) == 0) | 4630 else if(_tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1) == 0) |
4581 { | 4631 { |
4582 char buf[1025] = {0}; | 4632 char buf[1025] = {0}; |
4583 int x, count = dw_listbox_count(handle); | 4633 int x, count = dw_listbox_count(handle); |
4584 int basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8; | 4634 int basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8; |
4585 | 4635 |
4609 thisheight = _DW_SCROLLED_MIN_HEIGHT; | 4659 thisheight = _DW_SCROLLED_MIN_HEIGHT; |
4610 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) | 4660 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) |
4611 thisheight = _DW_SCROLLED_MAX_HEIGHT; | 4661 thisheight = _DW_SCROLLED_MAX_HEIGHT; |
4612 } | 4662 } |
4613 /* Entryfields and MLE */ | 4663 /* Entryfields and MLE */ |
4614 else if(_strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME)+1) == 0 || | 4664 else if(_tcsnicmp(tmpbuf, EDITCLASSNAME, _tcslen(EDITCLASSNAME)+1) == 0 || |
4615 _strnicmp(tmpbuf, RICHEDIT_CLASS, strlen(RICHEDIT_CLASS)+1) == 0) | 4665 _tcsnicmp(tmpbuf, RICHEDIT_CLASS, _tcslen(RICHEDIT_CLASS)+1) == 0) |
4616 { | 4666 { |
4617 LONG style = GetWindowLong(handle, GWL_STYLE); | 4667 LONG style = GetWindowLong(handle, GWL_STYLE); |
4618 if((style & ES_MULTILINE)) | 4668 if((style & ES_MULTILINE)) |
4619 { | 4669 { |
4620 unsigned long bytes; | 4670 unsigned long bytes; |
4675 thiswidth = 150; | 4725 thiswidth = 150; |
4676 extraheight = 6; | 4726 extraheight = 6; |
4677 } | 4727 } |
4678 } | 4728 } |
4679 /* Container */ | 4729 /* Container */ |
4680 else if(_strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW)+1)== 0) | 4730 else if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0) |
4681 { | 4731 { |
4682 DWORD result = ListView_ApproximateViewRect(handle, _DW_SCROLLED_MAX_WIDTH, _DW_SCROLLED_MAX_HEIGHT, -1); | 4732 DWORD result = ListView_ApproximateViewRect(handle, _DW_SCROLLED_MAX_WIDTH, _DW_SCROLLED_MAX_HEIGHT, -1); |
4683 | 4733 |
4684 thiswidth = LOWORD(result); | 4734 thiswidth = LOWORD(result); |
4685 thisheight = HIWORD(result); | 4735 thisheight = HIWORD(result); |
4692 thisheight = _DW_SCROLLED_MIN_HEIGHT; | 4742 thisheight = _DW_SCROLLED_MIN_HEIGHT; |
4693 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) | 4743 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) |
4694 thisheight = _DW_SCROLLED_MAX_HEIGHT; | 4744 thisheight = _DW_SCROLLED_MAX_HEIGHT; |
4695 } | 4745 } |
4696 /* Tree */ | 4746 /* Tree */ |
4697 else if(_strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW)+1)== 0) | 4747 else if(_tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)== 0) |
4698 { | 4748 { |
4699 thiswidth = (int)((_DW_SCROLLED_MAX_WIDTH + _DW_SCROLLED_MIN_WIDTH)/2); | 4749 thiswidth = (int)((_DW_SCROLLED_MAX_WIDTH + _DW_SCROLLED_MIN_WIDTH)/2); |
4700 thisheight = (int)((_DW_SCROLLED_MAX_HEIGHT + _DW_SCROLLED_MIN_HEIGHT)/2); | 4750 thisheight = (int)((_DW_SCROLLED_MAX_HEIGHT + _DW_SCROLLED_MIN_HEIGHT)/2); |
4701 } | 4751 } |
4702 /* Buttons */ | 4752 /* Buttons */ |
4703 else if(_strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1) == 0) | 4753 else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0) |
4704 { | 4754 { |
4705 ULONG style = GetWindowLong(handle, GWL_STYLE); | 4755 ULONG style = GetWindowLong(handle, GWL_STYLE); |
4706 | 4756 |
4707 /* Bitmap buttons */ | 4757 /* Bitmap buttons */ |
4708 if(hbm) | 4758 if(hbm) |
4721 { | 4771 { |
4722 extrawidth = 8; | 4772 extrawidth = 8; |
4723 extraheight = 8; | 4773 extraheight = 8; |
4724 } | 4774 } |
4725 } | 4775 } |
4726 else if(_strnicmp(tmpbuf, StatusbarClassName, strlen(StatusbarClassName)+1) == 0) | 4776 else if(_tcsnicmp(tmpbuf, StatusbarClassName, _tcslen(StatusbarClassName)+1) == 0) |
4727 { | 4777 { |
4728 extrawidth = 4; | 4778 extrawidth = 4; |
4729 extraheight = 2; | 4779 extraheight = 2; |
4730 } | 4780 } |
4731 | 4781 |
4744 */ | 4794 */ |
4745 int API dw_window_set_font(HWND handle, char *fontname) | 4795 int API dw_window_set_font(HWND handle, char *fontname) |
4746 { | 4796 { |
4747 HFONT hfont, oldfont; | 4797 HFONT hfont, oldfont; |
4748 ColorInfo *cinfo; | 4798 ColorInfo *cinfo; |
4749 char tmpbuf[100] = {0}; | 4799 TCHAR tmpbuf[100] = {0}; |
4750 | 4800 |
4751 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 4801 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
4752 | 4802 |
4753 GetClassName(handle, tmpbuf, 99); | 4803 GetClassName(handle, tmpbuf, 99); |
4754 if ( _strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0 ) | 4804 if ( _tcsnicmp( tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0 ) |
4755 { | 4805 { |
4756 /* groupbox */ | 4806 /* groupbox */ |
4757 Box *thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); | 4807 Box *thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); |
4758 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) | 4808 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) |
4759 { | 4809 { |
4859 char *str = NULL; | 4909 char *str = NULL; |
4860 char *bold = ""; | 4910 char *bold = ""; |
4861 char *italic = ""; | 4911 char *italic = ""; |
4862 LOGFONT lf = { 0 }; | 4912 LOGFONT lf = { 0 }; |
4863 Box *thisbox; | 4913 Box *thisbox; |
4864 char tmpbuf[100] = {0}; | 4914 TCHAR tmpbuf[100] = {0}; |
4865 | 4915 |
4866 GetClassName(handle, tmpbuf, 99); | 4916 GetClassName(handle, tmpbuf, 99); |
4867 if ( _strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0 ) | 4917 if ( _tcsnicmp( tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0 ) |
4868 { | 4918 { |
4869 /* groupbox */ | 4919 /* groupbox */ |
4870 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); | 4920 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); |
4871 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) | 4921 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) |
4872 { | 4922 { |
4905 */ | 4955 */ |
4906 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) | 4956 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) |
4907 { | 4957 { |
4908 ColorInfo *cinfo; | 4958 ColorInfo *cinfo; |
4909 Box *thisbox; | 4959 Box *thisbox; |
4910 char tmpbuf[100] = {0}; | 4960 TCHAR tmpbuf[100] = {0}; |
4911 | 4961 |
4912 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 4962 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
4913 | 4963 |
4914 GetClassName(handle, tmpbuf, 99); | 4964 GetClassName(handle, tmpbuf, 99); |
4915 | 4965 |
4916 if(_strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0) | 4966 if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW))==0) |
4917 { | 4967 { |
4918 cinfo->fore = fore = _internal_color(fore); | 4968 cinfo->fore = fore = _internal_color(fore); |
4919 cinfo->back = back = _internal_color(back); | 4969 cinfo->back = back = _internal_color(back); |
4920 | 4970 |
4921 ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore), | 4971 ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore), |
4928 DW_GREEN_VALUE(back), | 4978 DW_GREEN_VALUE(back), |
4929 DW_BLUE_VALUE(back))); | 4979 DW_BLUE_VALUE(back))); |
4930 InvalidateRgn(handle, NULL, TRUE); | 4980 InvalidateRgn(handle, NULL, TRUE); |
4931 return TRUE; | 4981 return TRUE; |
4932 } | 4982 } |
4933 else if ( _strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)) == 0 ) | 4983 else if ( _tcsnicmp( tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)) == 0 ) |
4934 { | 4984 { |
4935 /* groupbox */ | 4985 /* groupbox */ |
4936 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); | 4986 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); |
4937 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) | 4987 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) |
4938 { | 4988 { |
5035 flStyle |= WS_POPUPWINDOW; | 5085 flStyle |= WS_POPUPWINDOW; |
5036 | 5086 |
5037 if(flStyle & DW_FCF_TASKLIST || | 5087 if(flStyle & DW_FCF_TASKLIST || |
5038 flStyle & WS_VSCROLL /* This is deprecated and should go away in version 3? */) | 5088 flStyle & WS_VSCROLL /* This is deprecated and should go away in version 3? */) |
5039 { | 5089 { |
5040 hwndframe = CreateWindowExW(flStyleEx, UTF8toWide(ClassName), UTF8toWide(title), (flStyle | WS_CLIPCHILDREN) & 0xffdf0000, CW_USEDEFAULT, CW_USEDEFAULT, | 5090 hwndframe = CreateWindowEx(flStyleEx, ClassName, UTF8toWide(title), (flStyle | WS_CLIPCHILDREN) & 0xffdf0000, CW_USEDEFAULT, CW_USEDEFAULT, |
5041 0, 0, hwndOwner, NULL, DWInstance, NULL); | 5091 0, 0, hwndOwner, NULL, DWInstance, NULL); |
5042 } | 5092 } |
5043 else | 5093 else |
5044 { | 5094 { |
5045 flStyleEx |= WS_EX_TOOLWINDOW; | 5095 flStyleEx |= WS_EX_TOOLWINDOW; |
5046 | 5096 |
5047 hwndframe = CreateWindowExW(flStyleEx, UTF8toWide(ClassName), UTF8toWide(title), (flStyle | WS_CLIPCHILDREN) & 0xffff0000, CW_USEDEFAULT, CW_USEDEFAULT, | 5097 hwndframe = CreateWindowEx(flStyleEx, ClassName, UTF8toWide(title), (flStyle | WS_CLIPCHILDREN) & 0xffff0000, CW_USEDEFAULT, CW_USEDEFAULT, |
5048 0, 0, hwndOwner, NULL, DWInstance, NULL); | 5098 0, 0, hwndOwner, NULL, DWInstance, NULL); |
5049 } | 5099 } |
5050 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); | 5100 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); |
5051 | 5101 |
5052 if(hwndOwner) | 5102 if(hwndOwner) |
5205 DW_HWND_OBJECT, | 5255 DW_HWND_OBJECT, |
5206 NULL, | 5256 NULL, |
5207 DWInstance, | 5257 DWInstance, |
5208 NULL); | 5258 NULL); |
5209 | 5259 |
5210 newbox->grouphwnd = CreateWindowW(UTF8toWide(BUTTONCLASSNAME), | 5260 newbox->grouphwnd = CreateWindow(BUTTONCLASSNAME, |
5211 UTF8toWide(title), | 5261 UTF8toWide(title), |
5212 WS_CHILD | BS_GROUPBOX | | 5262 WS_CHILD | BS_GROUPBOX | |
5213 WS_VISIBLE | WS_CLIPCHILDREN, | 5263 WS_VISIBLE | WS_CLIPCHILDREN, |
5214 0,0,0,0, | 5264 0,0,0,0, |
5215 hwndframe, | 5265 hwndframe, |
5233 HWND hwndframe; | 5283 HWND hwndframe; |
5234 | 5284 |
5235 ccs.hWindowMenu = NULL; | 5285 ccs.hWindowMenu = NULL; |
5236 ccs.idFirstChild = 0; | 5286 ccs.idFirstChild = 0; |
5237 | 5287 |
5238 hwndframe = CreateWindow("MDICLIENT", | 5288 hwndframe = CreateWindow(TEXT("MDICLIENT"), |
5239 NULL, | 5289 NULL, |
5240 WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, | 5290 WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, |
5241 0,0,0,0, | 5291 0,0,0,0, |
5242 DW_HWND_OBJECT, | 5292 DW_HWND_OBJECT, |
5243 (HMENU)id, | 5293 (HMENU)id, |
5532 mii.wID = id; | 5582 mii.wID = id; |
5533 if (IsMenu((HMENU)submenu)) | 5583 if (IsMenu((HMENU)submenu)) |
5534 mii.hSubMenu = (HMENU)submenu; | 5584 mii.hSubMenu = (HMENU)submenu; |
5535 else | 5585 else |
5536 mii.hSubMenu = 0; | 5586 mii.hSubMenu = 0; |
5537 mii.dwTypeData = menutitle; | 5587 mii.dwTypeData = UTF8toWide(menutitle); |
5538 mii.cch = (UINT)strlen(menutitle); | 5588 mii.cch = (UINT)_tcslen(mii.dwTypeData); |
5539 | 5589 |
5540 InsertMenuItem(mymenu, 65535, TRUE, &mii); | 5590 InsertMenuItem(mymenu, 65535, TRUE, &mii); |
5541 | 5591 |
5542 _snprintf(buffer, 30, "_dw_id%ld", id); | 5592 _snprintf(buffer, 30, "_dw_id%ld", id); |
5543 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)mymenu ); | 5593 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)mymenu ); |
5861 * text: The text to be display by the static text widget. | 5911 * text: The text to be display by the static text widget. |
5862 * id: An ID to be used with dw_window_from_id() or 0L. | 5912 * id: An ID to be used with dw_window_from_id() or 0L. |
5863 */ | 5913 */ |
5864 HWND API dw_text_new(char *text, ULONG id) | 5914 HWND API dw_text_new(char *text, ULONG id) |
5865 { | 5915 { |
5866 HWND tmp = CreateWindowW(UTF8toWide(STATICCLASSNAME), | 5916 HWND tmp = CreateWindow(STATICCLASSNAME, |
5867 UTF8toWide(text), | 5917 UTF8toWide(text), |
5868 SS_NOPREFIX | SS_NOTIFY | WS_VISIBLE | | 5918 SS_NOPREFIX | SS_NOTIFY | WS_VISIBLE | |
5869 WS_CHILD | WS_CLIPCHILDREN, | 5919 WS_CHILD | WS_CLIPCHILDREN, |
5870 0,0,0,0, | 5920 0,0,0,0, |
5871 DW_HWND_OBJECT, | 5921 DW_HWND_OBJECT, |
5891 * text: The text to be display by the static text widget. | 5941 * text: The text to be display by the static text widget. |
5892 * id: An ID to be used with dw_window_from_id() or 0L. | 5942 * id: An ID to be used with dw_window_from_id() or 0L. |
5893 */ | 5943 */ |
5894 HWND API dw_status_text_new(char *text, ULONG id) | 5944 HWND API dw_status_text_new(char *text, ULONG id) |
5895 { | 5945 { |
5896 HWND tmp = CreateWindowW(UTF8toWide(StatusbarClassName), | 5946 HWND tmp = CreateWindow(StatusbarClassName, |
5897 UTF8toWide(text), | 5947 UTF8toWide(text), |
5898 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, | 5948 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, |
5899 0,0,0,0, | 5949 0,0,0,0, |
5900 DW_HWND_OBJECT, | 5950 DW_HWND_OBJECT, |
5901 (HMENU)id, | 5951 (HMENU)id, |
5948 * text: The default text to be in the entryfield widget. | 5998 * text: The default text to be in the entryfield widget. |
5949 * id: An ID to be used with dw_window_from_id() or 0L. | 5999 * id: An ID to be used with dw_window_from_id() or 0L. |
5950 */ | 6000 */ |
5951 HWND API dw_entryfield_new(char *text, ULONG id) | 6001 HWND API dw_entryfield_new(char *text, ULONG id) |
5952 { | 6002 { |
5953 HWND tmp = CreateWindowExW(WS_EX_CLIENTEDGE, | 6003 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, |
5954 UTF8toWide(EDITCLASSNAME), | 6004 EDITCLASSNAME, |
5955 UTF8toWide(text), | 6005 UTF8toWide(text), |
5956 ES_WANTRETURN | WS_CHILD | | 6006 ES_WANTRETURN | WS_CHILD | |
5957 WS_BORDER | ES_AUTOHSCROLL | | 6007 WS_BORDER | ES_AUTOHSCROLL | |
5958 WS_VISIBLE | WS_CLIPCHILDREN, | 6008 WS_VISIBLE | WS_CLIPCHILDREN, |
5959 0,0,0,0, | 6009 0,0,0,0, |
5977 * text: The default text to be in the entryfield widget. | 6027 * text: The default text to be in the entryfield widget. |
5978 * id: An ID to be used with dw_window_from_id() or 0L. | 6028 * id: An ID to be used with dw_window_from_id() or 0L. |
5979 */ | 6029 */ |
5980 HWND API dw_entryfield_password_new(char *text, ULONG id) | 6030 HWND API dw_entryfield_password_new(char *text, ULONG id) |
5981 { | 6031 { |
5982 HWND tmp = CreateWindowExW(WS_EX_CLIENTEDGE, | 6032 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, |
5983 UTF8toWide(EDITCLASSNAME), | 6033 EDITCLASSNAME, |
5984 UTF8toWide(text), | 6034 UTF8toWide(text), |
5985 ES_WANTRETURN | WS_CHILD | | 6035 ES_WANTRETURN | WS_CHILD | |
5986 ES_PASSWORD | WS_BORDER | WS_VISIBLE | | 6036 ES_PASSWORD | WS_BORDER | WS_VISIBLE | |
5987 ES_AUTOHSCROLL | WS_CLIPCHILDREN, | 6037 ES_AUTOHSCROLL | WS_CLIPCHILDREN, |
5988 0,0,0,0, | 6038 0,0,0,0, |
6019 * text: The default text to be in the combpbox widget. | 6069 * text: The default text to be in the combpbox widget. |
6020 * id: An ID to be used with dw_window_from_id() or 0L. | 6070 * id: An ID to be used with dw_window_from_id() or 0L. |
6021 */ | 6071 */ |
6022 HWND API dw_combobox_new(char *text, ULONG id) | 6072 HWND API dw_combobox_new(char *text, ULONG id) |
6023 { | 6073 { |
6024 HWND tmp = CreateWindowW(UTF8toWide(COMBOBOXCLASSNAME), | 6074 HWND tmp = CreateWindow(COMBOBOXCLASSNAME, |
6025 UTF8toWide(text), | 6075 UTF8toWide(text), |
6026 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL | | 6076 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL | |
6027 WS_CLIPCHILDREN | CBS_AUTOHSCROLL | WS_VISIBLE, | 6077 WS_CLIPCHILDREN | CBS_AUTOHSCROLL | WS_VISIBLE, |
6028 0,0,0,0, | 6078 0,0,0,0, |
6029 DW_HWND_OBJECT, | 6079 DW_HWND_OBJECT, |
6049 EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo2); | 6099 EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo2); |
6050 cinfo->buddy = cinfo2->buddy; | 6100 cinfo->buddy = cinfo2->buddy; |
6051 | 6101 |
6052 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); | 6102 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); |
6053 dw_window_set_font(tmp, DefaultFont); | 6103 dw_window_set_font(tmp, DefaultFont); |
6054 SetWindowTextW(tmp, UTF8toWide(text)); | 6104 SetWindowText(tmp, UTF8toWide(text)); |
6055 return tmp; | 6105 return tmp; |
6056 } | 6106 } |
6057 | 6107 |
6058 /* | 6108 /* |
6059 * Create a new button window (widget) to be packed. | 6109 * Create a new button window (widget) to be packed. |
6063 */ | 6113 */ |
6064 HWND API dw_button_new(char *text, ULONG id) | 6114 HWND API dw_button_new(char *text, ULONG id) |
6065 { | 6115 { |
6066 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); | 6116 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); |
6067 | 6117 |
6068 HWND tmp = CreateWindowW(UTF8toWide(BUTTONCLASSNAME), | 6118 HWND tmp = CreateWindow(BUTTONCLASSNAME, |
6069 UTF8toWide(text), | 6119 UTF8toWide(text), |
6070 WS_CHILD | BS_PUSHBUTTON | | 6120 WS_CHILD | BS_PUSHBUTTON | |
6071 WS_VISIBLE | WS_CLIPCHILDREN, | 6121 WS_VISIBLE | WS_CLIPCHILDREN, |
6072 0,0,0,0, | 6122 0,0,0,0, |
6073 DW_HWND_OBJECT, | 6123 DW_HWND_OBJECT, |
6273 * text: The text to be display by the static text widget. | 6323 * text: The text to be display by the static text widget. |
6274 * id: An ID to be used with dw_window_from_id() or 0L. | 6324 * id: An ID to be used with dw_window_from_id() or 0L. |
6275 */ | 6325 */ |
6276 HWND API dw_spinbutton_new(char *text, ULONG id) | 6326 HWND API dw_spinbutton_new(char *text, ULONG id) |
6277 { | 6327 { |
6278 HWND buddy = CreateWindowExW(WS_EX_CLIENTEDGE, | 6328 HWND buddy = CreateWindowEx(WS_EX_CLIENTEDGE, |
6279 UTF8toWide(EDITCLASSNAME), | 6329 EDITCLASSNAME, |
6280 UTF8toWide(text), | 6330 UTF8toWide(text), |
6281 WS_CHILD | WS_BORDER | WS_VISIBLE | | 6331 WS_CHILD | WS_BORDER | WS_VISIBLE | |
6282 ES_NUMBER | WS_CLIPCHILDREN, | 6332 ES_NUMBER | WS_CLIPCHILDREN, |
6283 0,0,0,0, | 6333 0,0,0,0, |
6284 DW_HWND_OBJECT, | 6334 DW_HWND_OBJECT, |
6328 * text: The text to be display by the static text widget. | 6378 * text: The text to be display by the static text widget. |
6329 * id: An ID to be used with dw_window_from_id() or 0L. | 6379 * id: An ID to be used with dw_window_from_id() or 0L. |
6330 */ | 6380 */ |
6331 HWND API dw_radiobutton_new(char *text, ULONG id) | 6381 HWND API dw_radiobutton_new(char *text, ULONG id) |
6332 { | 6382 { |
6333 HWND tmp = CreateWindowW(UTF8toWide(BUTTONCLASSNAME), | 6383 HWND tmp = CreateWindow(BUTTONCLASSNAME, |
6334 UTF8toWide(text), | 6384 UTF8toWide(text), |
6335 WS_CHILD | BS_AUTORADIOBUTTON | | 6385 WS_CHILD | BS_AUTORADIOBUTTON | |
6336 WS_CLIPCHILDREN | WS_VISIBLE, | 6386 WS_CLIPCHILDREN | WS_VISIBLE, |
6337 0,0,0,0, | 6387 0,0,0,0, |
6338 DW_HWND_OBJECT, | 6388 DW_HWND_OBJECT, |
6429 * id: An ID to be used with dw_window_from_id() or 0L. | 6479 * id: An ID to be used with dw_window_from_id() or 0L. |
6430 */ | 6480 */ |
6431 HWND API dw_checkbox_new(char *text, ULONG id) | 6481 HWND API dw_checkbox_new(char *text, ULONG id) |
6432 { | 6482 { |
6433 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); | 6483 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); |
6434 HWND tmp = CreateWindowW(UTF8toWide(BUTTONCLASSNAME), | 6484 HWND tmp = CreateWindow(BUTTONCLASSNAME, |
6435 UTF8toWide(text), | 6485 UTF8toWide(text), |
6436 WS_CHILD | BS_AUTOCHECKBOX | | 6486 WS_CHILD | BS_AUTOCHECKBOX | |
6437 BS_TEXT | WS_CLIPCHILDREN | WS_VISIBLE, | 6487 BS_TEXT | WS_CLIPCHILDREN | WS_VISIBLE, |
6438 0,0,0,0, | 6488 0,0,0,0, |
6439 DW_HWND_OBJECT, | 6489 DW_HWND_OBJECT, |
6662 * text: The text associsated with a given window. | 6712 * text: The text associsated with a given window. |
6663 */ | 6713 */ |
6664 void API dw_window_set_text(HWND handle, char *text) | 6714 void API dw_window_set_text(HWND handle, char *text) |
6665 { | 6715 { |
6666 Box *thisbox; | 6716 Box *thisbox; |
6667 char tmpbuf[100] = {0}; | 6717 TCHAR tmpbuf[100] = {0}, *wtext = UTF8toWide(text); |
6668 LPWSTR wtext = UTF8toWide(text); | |
6669 | 6718 |
6670 GetClassName(handle, tmpbuf, 99); | 6719 GetClassName(handle, tmpbuf, 99); |
6671 | 6720 |
6672 SetWindowTextW(handle, wtext); | 6721 SetWindowText(handle, wtext); |
6673 | 6722 |
6674 /* Combobox */ | 6723 /* Combobox */ |
6675 if ( _strnicmp( tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1) == 0 ) | 6724 if ( _tcsnicmp( tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1) == 0 ) |
6676 SendMessage(handle, CB_SETEDITSEL, 0, MAKELPARAM(-1, 0)); | 6725 SendMessage(handle, CB_SETEDITSEL, 0, MAKELPARAM(-1, 0)); |
6677 else if ( _strnicmp( tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1) == 0 ) | 6726 else if ( _tcsnicmp( tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1) == 0 ) |
6678 { | 6727 { |
6679 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 6728 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
6680 if( cinfo && cinfo->buddy ) | 6729 if( cinfo && cinfo->buddy ) |
6681 SetWindowTextW( cinfo->buddy, wtext ); | 6730 SetWindowText( cinfo->buddy, wtext ); |
6682 } | 6731 } |
6683 else if ( _strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0 ) | 6732 else if ( _tcsnicmp( tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0 ) |
6684 { | 6733 { |
6685 /* groupbox */ | 6734 /* groupbox */ |
6686 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); | 6735 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); |
6687 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) | 6736 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) |
6688 SetWindowTextW( thisbox->grouphwnd, wtext ); | 6737 SetWindowText( thisbox->grouphwnd, wtext ); |
6689 } | 6738 } |
6690 /* If we changed the text... */ | 6739 /* If we changed the text... */ |
6691 { | 6740 { |
6692 Item *item = _box_item(handle); | 6741 Item *item = _box_item(handle); |
6693 | 6742 |
6723 * Returns: | 6772 * Returns: |
6724 * text: The text associsated with a given window. | 6773 * text: The text associsated with a given window. |
6725 */ | 6774 */ |
6726 char * API dw_window_get_text(HWND handle) | 6775 char * API dw_window_get_text(HWND handle) |
6727 { | 6776 { |
6728 char tmpbuf[100] = {0}, *retbuf; | 6777 char *retbuf = NULL; |
6729 LPWSTR tempbuf; | 6778 TCHAR *tempbuf, tmpbuf[100] = { 0 }; |
6730 int wlen, len; | 6779 int len; |
6731 | 6780 |
6732 GetClassName(handle, tmpbuf, 99); | 6781 GetClassName(handle, tmpbuf, 99); |
6733 | 6782 |
6734 if ( _strnicmp( tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1) == 0 ) | 6783 if ( _tcsnicmp( tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1) == 0 ) |
6735 { | 6784 { |
6736 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 6785 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
6737 | 6786 |
6738 if( cinfo && cinfo->buddy ) | 6787 if( cinfo && cinfo->buddy ) |
6739 handle = cinfo->buddy; | 6788 handle = cinfo->buddy; |
6742 } | 6791 } |
6743 | 6792 |
6744 /* Figure out the wide length, allocate a temp buffer | 6793 /* Figure out the wide length, allocate a temp buffer |
6745 * and fill it with the current text. | 6794 * and fill it with the current text. |
6746 */ | 6795 */ |
6747 wlen = GetWindowTextLengthW(handle); | 6796 len = GetWindowTextLength(handle); |
6748 tempbuf = _alloca(wlen * sizeof(WCHAR)); | 6797 if((tempbuf = _alloca(len * sizeof(TCHAR)))) |
6749 GetWindowTextW(handle, tempbuf, wlen); | 6798 GetWindowText(handle, tempbuf, len); |
6750 | 6799 |
6751 /* Figure out the UTF8 length, allocate a return buffer | 6800 /* Figure out the UTF8 length, allocate a return buffer |
6752 * and fill it with the UTF8 text and return it. | 6801 * and fill it with the UTF8 text and return it. |
6753 */ | 6802 */ |
6754 len = WideCharToMultiByte(CP_UTF8, 0, tempbuf, -1, NULL, 0, NULL, NULL); | 6803 if(tempbuf && (retbuf = WideToUTF8(tempbuf))) |
6755 retbuf = (char *)calloc(1, len); | 6804 retbuf = strdup(retbuf); |
6756 WideCharToMultiByte(CP_UTF8, 0, tempbuf, -1, retbuf, len, NULL, NULL); | |
6757 | |
6758 return retbuf; | 6805 return retbuf; |
6759 } | 6806 } |
6760 | 6807 |
6761 /* | 6808 /* |
6762 * Disables given window (widget). | 6809 * Disables given window (widget). |
6831 | 6878 |
6832 /* Internal box packing function called by the other 3 functions */ | 6879 /* Internal box packing function called by the other 3 functions */ |
6833 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname) | 6880 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname) |
6834 { | 6881 { |
6835 Box *thisbox = NULL; | 6882 Box *thisbox = NULL; |
6836 char tmpbuf[100] = {0}; | 6883 TCHAR tmpbuf[100] = {0}; |
6837 | 6884 |
6838 /* | 6885 /* |
6839 * If you try and pack an item into itself VERY bad things can happen; like at least an | 6886 * If you try and pack an item into itself VERY bad things can happen; like at least an |
6840 * infinite loop on GTK! Lets be safe! | 6887 * infinite loop on GTK! Lets be safe! |
6841 */ | 6888 */ |
6846 } | 6893 } |
6847 | 6894 |
6848 GetClassName(box, tmpbuf, 99); | 6895 GetClassName(box, tmpbuf, 99); |
6849 | 6896 |
6850 /* If we are in a scrolled box... extract the interal box */ | 6897 /* If we are in a scrolled box... extract the interal box */ |
6851 if(_strnicmp(tmpbuf, ScrollClassName, strlen(ScrollClassName)+1)==0) | 6898 if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName)+1)==0) |
6852 { | 6899 { |
6853 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box, GWLP_USERDATA); | 6900 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box, GWLP_USERDATA); |
6854 if(cinfo) | 6901 if(cinfo) |
6855 { | 6902 { |
6856 box = cinfo->buddy; | 6903 box = cinfo->buddy; |
6857 thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA); | 6904 thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA); |
6858 } | 6905 } |
6859 } | 6906 } |
6860 else //if(_strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1)==0) | 6907 else //if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==0) |
6861 thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA); | 6908 thisbox = (Box *)GetWindowLongPtr(box, GWLP_USERDATA); |
6862 if(thisbox) | 6909 if(thisbox) |
6863 { | 6910 { |
6864 int z, x = 0; | 6911 int z, x = 0; |
6865 Item *tmpitem, *thisitem = thisbox->items; | 6912 Item *tmpitem, *thisitem = thisbox->items; |
6885 if(vsize && !height) | 6932 if(vsize && !height) |
6886 height = 1; | 6933 height = 1; |
6887 if(hsize && !width) | 6934 if(hsize && !width) |
6888 width = 1; | 6935 width = 1; |
6889 | 6936 |
6890 if(_strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1)==0) | 6937 if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==0) |
6891 tmpitem[index].type = TYPEBOX; | 6938 tmpitem[index].type = TYPEBOX; |
6892 else | 6939 else |
6893 { | 6940 { |
6894 if(_strnicmp(tmpbuf, "SysMonthCal32", 13)==0) | 6941 if(_tcsnicmp(tmpbuf, "SysMonthCal32", 13)==0) |
6895 { | 6942 { |
6896 RECT rc; | 6943 RECT rc; |
6897 MonthCal_GetMinReqRect(item, &rc); | 6944 MonthCal_GetMinReqRect(item, &rc); |
6898 width = 1 + rc.right - rc.left; | 6945 width = 1 + rc.right - rc.left; |
6899 height = 1 + rc.bottom - rc.top; | 6946 height = 1 + rc.bottom - rc.top; |
6927 free(thisitem); | 6974 free(thisitem); |
6928 | 6975 |
6929 thisbox->count++; | 6976 thisbox->count++; |
6930 | 6977 |
6931 SetParent(item, box); | 6978 SetParent(item, box); |
6932 if(strncmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0) | 6979 if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0) |
6933 { | 6980 { |
6934 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(item, GWLP_USERDATA); | 6981 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(item, GWLP_USERDATA); |
6935 | 6982 |
6936 if(cinfo) | 6983 if(cinfo) |
6937 { | 6984 { |
7051 * width: Width in pixels of the item or NULL if not needed. | 7098 * width: Width in pixels of the item or NULL if not needed. |
7052 * height: Height in pixels of the item or NULL if not needed. | 7099 * height: Height in pixels of the item or NULL if not needed. |
7053 */ | 7100 */ |
7054 void API dw_window_get_preferred_size(HWND handle, int *width, int *height) | 7101 void API dw_window_get_preferred_size(HWND handle, int *width, int *height) |
7055 { | 7102 { |
7056 char tmpbuf[100] = {0}; | 7103 TCHAR tmpbuf[100] = {0}; |
7057 | 7104 |
7058 GetClassName(handle, tmpbuf, 99); | 7105 GetClassName(handle, tmpbuf, 99); |
7059 | 7106 |
7060 if(_strnicmp(tmpbuf, ClassName, strlen(ClassName)+1) == 0) | 7107 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1) == 0) |
7061 { | 7108 { |
7062 unsigned long thiswidth = 0, thisheight = 0; | 7109 unsigned long thiswidth = 0, thisheight = 0; |
7063 | 7110 |
7064 /* Get the size with the border */ | 7111 /* Get the size with the border */ |
7065 _get_window_for_size(handle, &thiswidth, &thisheight); | 7112 _get_window_for_size(handle, &thiswidth, &thisheight); |
7066 | 7113 |
7067 /* Return what was requested */ | 7114 /* Return what was requested */ |
7068 if(width) *width = (int)thiswidth; | 7115 if(width) *width = (int)thiswidth; |
7069 if(height) *height = (int)thisheight; | 7116 if(height) *height = (int)thisheight; |
7070 } | 7117 } |
7071 else if(_strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0) | 7118 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1) == 0) |
7072 { | 7119 { |
7073 Box *thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); | 7120 Box *thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); |
7074 | 7121 |
7075 if(thisbox) | 7122 if(thisbox) |
7076 { | 7123 { |
7279 */ | 7326 */ |
7280 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) | 7327 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) |
7281 { | 7328 { |
7282 ULONG tmp, currentstyle; | 7329 ULONG tmp, currentstyle; |
7283 ColorInfo *cinfo; | 7330 ColorInfo *cinfo; |
7284 char tmpbuf[100] = {0}; | 7331 TCHAR tmpbuf[100] = {0}; |
7285 | 7332 |
7286 if(!handle) | 7333 if(!handle) |
7287 return; | 7334 return; |
7288 | 7335 |
7289 if(handle < (HWND)65536) | 7336 if(handle < (HWND)65536) |
7307 | 7354 |
7308 tmp = currentstyle | mask; | 7355 tmp = currentstyle | mask; |
7309 tmp ^= mask; | 7356 tmp ^= mask; |
7310 tmp |= style; | 7357 tmp |= style; |
7311 | 7358 |
7312 if(_strnicmp(tmpbuf, ClassName, strlen(ClassName)+1)==0) | 7359 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0) |
7313 { | 7360 { |
7314 tmp = tmp & 0xffff0000; | 7361 tmp = tmp & 0xffff0000; |
7315 #ifdef AEROGLASS | 7362 #ifdef AEROGLASS |
7316 if(mask & DW_FCF_COMPOSITED && _DwmExtendFrameIntoClientArea && _dw_composition) | 7363 if(mask & DW_FCF_COMPOSITED && _DwmExtendFrameIntoClientArea && _dw_composition) |
7317 { | 7364 { |
7408 { | 7455 { |
7409 array[z] = calloc(1, sizeof(NotebookPage)); | 7456 array[z] = calloc(1, sizeof(NotebookPage)); |
7410 array[z]->realid = refid; | 7457 array[z]->realid = refid; |
7411 array[z]->item.mask = TCIF_TEXT; | 7458 array[z]->item.mask = TCIF_TEXT; |
7412 array[z]->item.iImage = -1; | 7459 array[z]->item.iImage = -1; |
7413 array[z]->item.pszText = ""; | 7460 array[z]->item.pszText = TEXT(""); |
7414 TabCtrl_InsertItem(handle, z, &(array[z]->item)); | 7461 TabCtrl_InsertItem(handle, z, &(array[z]->item)); |
7415 return refid; | 7462 return refid; |
7416 } | 7463 } |
7417 } | 7464 } |
7418 } | 7465 } |
7438 pageid = _findnotebookid(array, pageidx); | 7485 pageid = _findnotebookid(array, pageidx); |
7439 | 7486 |
7440 if(pageid > -1 && array[pageid]) | 7487 if(pageid > -1 && array[pageid]) |
7441 { | 7488 { |
7442 array[pageid]->item.mask = TCIF_TEXT; | 7489 array[pageid]->item.mask = TCIF_TEXT; |
7443 array[pageid]->item.pszText = text; | 7490 array[pageid]->item.pszText = UTF8toWide(text); |
7444 TabCtrl_SetItem(handle, pageid, &(array[pageid]->item)); | 7491 TabCtrl_SetItem(handle, pageid, &(array[pageid]->item)); |
7445 _resize_notebook_page(handle, pageid); | 7492 _resize_notebook_page(handle, pageid); |
7446 } | 7493 } |
7447 } | 7494 } |
7448 | 7495 |
7595 * handle: Handle to the listbox to be appended to. | 7642 * handle: Handle to the listbox to be appended to. |
7596 * text: Text to append into listbox. | 7643 * text: Text to append into listbox. |
7597 */ | 7644 */ |
7598 void API dw_listbox_append(HWND handle, char *text) | 7645 void API dw_listbox_append(HWND handle, char *text) |
7599 { | 7646 { |
7600 char tmpbuf[100] = {0}; | 7647 TCHAR tmpbuf[100] = {0}; |
7601 | 7648 |
7602 GetClassName(handle, tmpbuf, 99); | 7649 GetClassName(handle, tmpbuf, 99); |
7603 | 7650 |
7604 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7651 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7605 SendMessage(handle, | 7652 SendMessage(handle, |
7606 CB_ADDSTRING, | 7653 CB_ADDSTRING, |
7607 0, (LPARAM)text); | 7654 0, (LPARAM)UTF8toWide(text)); |
7608 else | 7655 else |
7609 SendMessage(handle, | 7656 SendMessage(handle, |
7610 LB_ADDSTRING, | 7657 LB_ADDSTRING, |
7611 0, (LPARAM)text); | 7658 0, (LPARAM)UTF8toWide(text)); |
7612 } | 7659 } |
7613 | 7660 |
7614 /* | 7661 /* |
7615 * Appends the specified text items to the listbox's (or combobox) entry list. | 7662 * Appends the specified text items to the listbox's (or combobox) entry list. |
7616 * Parameters: | 7663 * Parameters: |
7618 * text: Text strings to append into listbox. | 7665 * text: Text strings to append into listbox. |
7619 * count: Number of text strings to append | 7666 * count: Number of text strings to append |
7620 */ | 7667 */ |
7621 void API dw_listbox_list_append(HWND handle, char **text, int count) | 7668 void API dw_listbox_list_append(HWND handle, char **text, int count) |
7622 { | 7669 { |
7623 char tmpbuf[100] = {0}; | 7670 TCHAR tmpbuf[100] = {0}; |
7624 int listbox_type; | 7671 int listbox_type; |
7625 int i; | 7672 int i; |
7626 | 7673 |
7627 GetClassName(handle, tmpbuf, 99); | 7674 GetClassName(handle, tmpbuf, 99); |
7628 | 7675 |
7629 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7676 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7630 listbox_type = CB_ADDSTRING; | 7677 listbox_type = CB_ADDSTRING; |
7631 else | 7678 else |
7632 listbox_type = LB_ADDSTRING; | 7679 listbox_type = LB_ADDSTRING; |
7633 | 7680 |
7634 for(i=0;i<count;i++) | 7681 for(i=0;i<count;i++) |
7635 SendMessage(handle,(WPARAM)listbox_type,0,(LPARAM)text[i]); | 7682 SendMessage(handle,(WPARAM)listbox_type,0,(LPARAM)UTF8toWide(text[i])); |
7636 } | 7683 } |
7637 | 7684 |
7638 /* | 7685 /* |
7639 * Inserts the specified text to the listbox's (or combobox) entry list. | 7686 * Inserts the specified text to the listbox's (or combobox) entry list. |
7640 * Parameters: | 7687 * Parameters: |
7642 * text: Text to append into listbox. | 7689 * text: Text to append into listbox. |
7643 * pos: 0 based position to insert text | 7690 * pos: 0 based position to insert text |
7644 */ | 7691 */ |
7645 void API dw_listbox_insert(HWND handle, char *text, int pos) | 7692 void API dw_listbox_insert(HWND handle, char *text, int pos) |
7646 { | 7693 { |
7647 char tmpbuf[100] = {0}; | 7694 TCHAR tmpbuf[100] = {0}; |
7648 | 7695 |
7649 GetClassName(handle, tmpbuf, 99); | 7696 GetClassName(handle, tmpbuf, 99); |
7650 | 7697 |
7651 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7698 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7652 SendMessage(handle, | 7699 SendMessage(handle, |
7653 CB_INSERTSTRING, | 7700 CB_INSERTSTRING, |
7654 pos, (LPARAM)text); | 7701 pos, (LPARAM)UTF8toWide(text)); |
7655 else | 7702 else |
7656 SendMessage(handle, | 7703 SendMessage(handle, |
7657 LB_INSERTSTRING, | 7704 LB_INSERTSTRING, |
7658 pos, (LPARAM)text); | 7705 pos, (LPARAM)UTF8toWide(text)); |
7659 } | 7706 } |
7660 | 7707 |
7661 /* | 7708 /* |
7662 * Clears the listbox's (or combobox) list of all entries. | 7709 * Clears the listbox's (or combobox) list of all entries. |
7663 * Parameters: | 7710 * Parameters: |
7664 * handle: Handle to the listbox to be cleared. | 7711 * handle: Handle to the listbox to be cleared. |
7665 */ | 7712 */ |
7666 void API dw_listbox_clear(HWND handle) | 7713 void API dw_listbox_clear(HWND handle) |
7667 { | 7714 { |
7668 char tmpbuf[100] = {0}; | 7715 TCHAR tmpbuf[100] = {0}; |
7669 | 7716 |
7670 GetClassName(handle, tmpbuf, 99); | 7717 GetClassName(handle, tmpbuf, 99); |
7671 | 7718 |
7672 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7719 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7673 { | 7720 { |
7674 char *buf = dw_window_get_text(handle); | 7721 char *buf = dw_window_get_text(handle); |
7675 | 7722 |
7676 SendMessage(handle, | 7723 SendMessage(handle, |
7677 CB_RESETCONTENT, 0L, 0L); | 7724 CB_RESETCONTENT, 0L, 0L); |
7694 * index: Index into the list to be queried. | 7741 * index: Index into the list to be queried. |
7695 * buffer: Buffer where text will be copied. | 7742 * buffer: Buffer where text will be copied. |
7696 */ | 7743 */ |
7697 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | 7744 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) |
7698 { | 7745 { |
7699 char tmpbuf[100] = {0}; | 7746 TCHAR tmpbuf[100] = {0}; |
7700 | 7747 |
7701 GetClassName(handle, tmpbuf, 99); | 7748 GetClassName(handle, tmpbuf, 99); |
7702 | 7749 |
7703 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7750 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7704 { | 7751 { |
7705 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0); | 7752 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0); |
7706 SendMessage(handle, CB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer); | 7753 SendMessage(handle, CB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer); |
7707 } | 7754 } |
7708 else | 7755 else |
7723 * buffer: Buffer where text will be copied. | 7770 * buffer: Buffer where text will be copied. |
7724 * length: Length of the buffer (including NULL). | 7771 * length: Length of the buffer (including NULL). |
7725 */ | 7772 */ |
7726 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | 7773 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) |
7727 { | 7774 { |
7728 char tmpbuf[100] = {0}; | 7775 TCHAR tmpbuf[100] = {0}; |
7729 unsigned int len; | 7776 unsigned int len; |
7730 | 7777 |
7731 if(!buffer || !length) | 7778 if(!buffer || !length) |
7732 return; | 7779 return; |
7733 | 7780 |
7734 buffer[0] = 0; | 7781 buffer[0] = 0; |
7735 | 7782 |
7736 GetClassName(handle, tmpbuf, 99); | 7783 GetClassName(handle, tmpbuf, 99); |
7737 | 7784 |
7738 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7785 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7739 { | 7786 { |
7740 len = (int)SendMessage(handle, CB_GETLBTEXTLEN, (WPARAM)index, 0); | 7787 len = (int)SendMessage(handle, CB_GETLBTEXTLEN, (WPARAM)index, 0); |
7741 | 7788 |
7742 if(len < length && len != CB_ERR) | 7789 if(len < length && len != CB_ERR) |
7743 SendMessage(handle, | 7790 SendMessage(handle, |
7758 * Parameters: | 7805 * Parameters: |
7759 * handle: Handle to the listbox to be queried. | 7806 * handle: Handle to the listbox to be queried. |
7760 */ | 7807 */ |
7761 int API dw_listbox_selected(HWND handle) | 7808 int API dw_listbox_selected(HWND handle) |
7762 { | 7809 { |
7763 char tmpbuf[100] = {0}; | 7810 TCHAR tmpbuf[100] = {0}; |
7764 | 7811 |
7765 GetClassName(handle, tmpbuf, 99); | 7812 GetClassName(handle, tmpbuf, 99); |
7766 | 7813 |
7767 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7814 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7768 return (unsigned int)SendMessage(handle, | 7815 return (unsigned int)SendMessage(handle, |
7769 CB_GETCURSEL, | 7816 CB_GETCURSEL, |
7770 0, 0); | 7817 0, 0); |
7771 | 7818 |
7772 return (unsigned int)SendMessage(handle, | 7819 return (unsigned int)SendMessage(handle, |
7781 * where: Either the previous return or -1 to restart. | 7828 * where: Either the previous return or -1 to restart. |
7782 */ | 7829 */ |
7783 int API dw_listbox_selected_multi(HWND handle, int where) | 7830 int API dw_listbox_selected_multi(HWND handle, int where) |
7784 { | 7831 { |
7785 int *array, count, z; | 7832 int *array, count, z; |
7786 char tmpbuf[100] = {0}; | 7833 TCHAR tmpbuf[100] = {0}; |
7787 | 7834 |
7788 GetClassName(handle, tmpbuf, 99); | 7835 GetClassName(handle, tmpbuf, 99); |
7789 | 7836 |
7790 /* This doesn't work on comboboxes */ | 7837 /* This doesn't work on comboboxes */ |
7791 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7838 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7792 return -1; | 7839 return -1; |
7793 | 7840 |
7794 count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0); | 7841 count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0); |
7795 if(count > 0) | 7842 if(count > 0) |
7796 { | 7843 { |
7824 * index: Item index. | 7871 * index: Item index. |
7825 * state: TRUE if selected FALSE if unselected. | 7872 * state: TRUE if selected FALSE if unselected. |
7826 */ | 7873 */ |
7827 void API dw_listbox_select(HWND handle, int index, int state) | 7874 void API dw_listbox_select(HWND handle, int index, int state) |
7828 { | 7875 { |
7829 char tmpbuf[100] = {0}; | 7876 TCHAR tmpbuf[100] = {0}; |
7830 | 7877 |
7831 GetClassName(handle, tmpbuf, 99); | 7878 GetClassName(handle, tmpbuf, 99); |
7832 | 7879 |
7833 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7880 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7834 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0); | 7881 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0); |
7835 else | 7882 else |
7836 { | 7883 { |
7837 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0); | 7884 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0); |
7838 SendMessage(handle, LB_SETSEL, (WPARAM)state, (LPARAM)index); | 7885 SendMessage(handle, LB_SETSEL, (WPARAM)state, (LPARAM)index); |
7846 * handle: Handle to the listbox to be set. | 7893 * handle: Handle to the listbox to be set. |
7847 * index: Item index. | 7894 * index: Item index. |
7848 */ | 7895 */ |
7849 void API dw_listbox_delete(HWND handle, int index) | 7896 void API dw_listbox_delete(HWND handle, int index) |
7850 { | 7897 { |
7851 char tmpbuf[100] = {0}; | 7898 TCHAR tmpbuf[100] = {0}; |
7852 | 7899 |
7853 GetClassName(handle, tmpbuf, 99); | 7900 GetClassName(handle, tmpbuf, 99); |
7854 | 7901 |
7855 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7902 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7856 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0); | 7903 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0); |
7857 else | 7904 else |
7858 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); | 7905 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); |
7859 } | 7906 } |
7860 | 7907 |
7863 * Parameters: | 7910 * Parameters: |
7864 * handle: Handle to the listbox to be cleared. | 7911 * handle: Handle to the listbox to be cleared. |
7865 */ | 7912 */ |
7866 int API dw_listbox_count(HWND handle) | 7913 int API dw_listbox_count(HWND handle) |
7867 { | 7914 { |
7868 char tmpbuf[100] = {0}; | 7915 TCHAR tmpbuf[100] = {0}; |
7869 | 7916 |
7870 GetClassName(handle, tmpbuf, 99); | 7917 GetClassName(handle, tmpbuf, 99); |
7871 | 7918 |
7872 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7919 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7873 return (int)SendMessage(handle, | 7920 return (int)SendMessage(handle, |
7874 CB_GETCOUNT,0L, 0L); | 7921 CB_GETCOUNT,0L, 0L); |
7875 | 7922 |
7876 return (int)SendMessage(handle, | 7923 return (int)SendMessage(handle, |
7877 LB_GETCOUNT,0L, 0L); | 7924 LB_GETCOUNT,0L, 0L); |
7883 * handle: Handle to the listbox to be cleared. | 7930 * handle: Handle to the listbox to be cleared. |
7884 * top: Index to the top item. | 7931 * top: Index to the top item. |
7885 */ | 7932 */ |
7886 void API dw_listbox_set_top(HWND handle, int top) | 7933 void API dw_listbox_set_top(HWND handle, int top) |
7887 { | 7934 { |
7888 char tmpbuf[100] = {0}; | 7935 TCHAR tmpbuf[100] = {0}; |
7889 | 7936 |
7890 GetClassName(handle, tmpbuf, 99); | 7937 GetClassName(handle, tmpbuf, 99); |
7891 | 7938 |
7892 /* This doesn't work on comboboxes */ | 7939 /* This doesn't work on comboboxes */ |
7893 if(_strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) | 7940 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0) |
7894 return; | 7941 return; |
7895 | 7942 |
7896 SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0); | 7943 SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0); |
7897 } | 7944 } |
7898 | 7945 |
7904 * startpoint: Point to start entering text. | 7951 * startpoint: Point to start entering text. |
7905 */ | 7952 */ |
7906 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) | 7953 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) |
7907 { | 7954 { |
7908 int textlen, len = GetWindowTextLength(handle); | 7955 int textlen, len = GetWindowTextLength(handle); |
7909 char *tmpbuf; | 7956 TCHAR *tmpbuf; |
7910 | 7957 |
7911 if(startpoint < 0) | 7958 if(startpoint < 0) |
7912 startpoint = 0; | 7959 startpoint = 0; |
7913 | 7960 |
7914 if(!buffer || (textlen = (int)strlen(buffer)) < 1) | 7961 if(!buffer || (textlen = (int)strlen(buffer)) < 1) |
7915 return startpoint; | 7962 return startpoint; |
7916 | 7963 |
7917 tmpbuf = calloc(1, len + textlen + startpoint + 2); | 7964 tmpbuf = calloc(sizeof(TCHAR), len + textlen + startpoint + 2); |
7918 | 7965 |
7919 if(len) | 7966 if(len) |
7920 { | 7967 { |
7921 char *dest, *start; | 7968 TCHAR *dest, *start; |
7922 int copylen = len - startpoint; | 7969 int copylen = len - startpoint; |
7923 | 7970 |
7924 GetWindowText(handle, tmpbuf, len+1); | 7971 GetWindowText(handle, tmpbuf, len+1); |
7925 | 7972 |
7926 dest = &tmpbuf[startpoint+textlen]; | 7973 dest = &tmpbuf[startpoint+textlen]; |
7927 start = &tmpbuf[startpoint]; | 7974 start = &tmpbuf[startpoint]; |
7928 | 7975 |
7929 if(copylen > 0) | 7976 if(copylen > 0) |
7930 memcpy(dest, start, copylen); | 7977 memcpy(dest, start, copylen*sizeof(TCHAR)); |
7931 } | 7978 } |
7932 memcpy(&tmpbuf[startpoint], buffer, textlen); | 7979 memcpy(&tmpbuf[startpoint], UTF8toWide(buffer), textlen*sizeof(TCHAR)); |
7933 | 7980 |
7934 SetWindowText(handle, tmpbuf); | 7981 SetWindowText(handle, tmpbuf); |
7935 | 7982 |
7936 free(tmpbuf); | 7983 free(tmpbuf); |
7937 return (startpoint + textlen); | 7984 return (startpoint + textlen); |
7946 * length: Amount of text to be grabbed. | 7993 * length: Amount of text to be grabbed. |
7947 */ | 7994 */ |
7948 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | 7995 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) |
7949 { | 7996 { |
7950 int max, len = GetWindowTextLength(handle); | 7997 int max, len = GetWindowTextLength(handle); |
7951 char *tmpbuf = calloc(1, len+2); | 7998 TCHAR *tmpbuf = calloc(sizeof(TCHAR), len+2); |
7952 | 7999 |
7953 if(len) | 8000 if(len) |
7954 GetWindowText(handle, tmpbuf, len+1); | 8001 GetWindowText(handle, tmpbuf, len+1); |
7955 | 8002 |
7956 buffer[0] = 0; | 8003 buffer[0] = 0; |
7957 | 8004 |
7958 if(startpoint < len) | 8005 if(startpoint < len) |
7959 { | 8006 { |
7960 max = MIN(length, len - startpoint); | 8007 max = MIN(length, len - startpoint); |
7961 | 8008 |
7962 memcpy(buffer, &tmpbuf[startpoint], max); | 8009 memcpy(buffer, WideToUTF8(&tmpbuf[startpoint]), max); |
7963 buffer[max] = '\0'; | 8010 buffer[max] = '\0'; |
7964 } | 8011 } |
7965 | 8012 |
7966 free(tmpbuf); | 8013 free(tmpbuf); |
7967 } | 8014 } |
7989 * length: Amount of text to be deleted. | 8036 * length: Amount of text to be deleted. |
7990 */ | 8037 */ |
7991 void API dw_mle_delete(HWND handle, int startpoint, int length) | 8038 void API dw_mle_delete(HWND handle, int startpoint, int length) |
7992 { | 8039 { |
7993 int len = GetWindowTextLength(handle); | 8040 int len = GetWindowTextLength(handle); |
7994 char *tmpbuf = calloc(1, len+2); | 8041 TCHAR *tmpbuf = calloc(sizeof(TCHAR), len+2); |
7995 | 8042 |
7996 GetWindowText(handle, tmpbuf, len+1); | 8043 GetWindowText(handle, tmpbuf, len+1); |
7997 | 8044 |
7998 if(startpoint + length < len) | 8045 if(startpoint + length < len) |
7999 { | 8046 { |
8000 strcpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]); | 8047 _tcscpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]); |
8001 | 8048 |
8002 SetWindowText(handle, tmpbuf); | 8049 SetWindowText(handle, tmpbuf); |
8003 } | 8050 } |
8004 | 8051 |
8005 free(tmpbuf); | 8052 free(tmpbuf); |
8010 * Parameters: | 8057 * Parameters: |
8011 * handle: Handle to the MLE to be cleared. | 8058 * handle: Handle to the MLE to be cleared. |
8012 */ | 8059 */ |
8013 void API dw_mle_clear(HWND handle) | 8060 void API dw_mle_clear(HWND handle) |
8014 { | 8061 { |
8015 SetWindowText(handle, ""); | 8062 SetWindowText(handle, TEXT("")); |
8016 } | 8063 } |
8017 | 8064 |
8018 /* | 8065 /* |
8019 * Sets the visible line of an MLE box. | 8066 * Sets the visible line of an MLE box. |
8020 * Parameters: | 8067 * Parameters: |
8084 * flags: Search specific flags. | 8131 * flags: Search specific flags. |
8085 */ | 8132 */ |
8086 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | 8133 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) |
8087 { | 8134 { |
8088 int len = GetWindowTextLength(handle); | 8135 int len = GetWindowTextLength(handle); |
8089 char *tmpbuf = calloc(1, len+2); | 8136 TCHAR *tmpbuf = calloc(sizeof(TCHAR), len+2); |
8137 TCHAR *searchtext = UTF8toWide(text); | |
8090 int z, textlen, retval = 0; | 8138 int z, textlen, retval = 0; |
8091 | 8139 |
8092 GetWindowText(handle, tmpbuf, len+1); | 8140 GetWindowText(handle, tmpbuf, len+1); |
8093 | 8141 |
8094 textlen = (int)strlen(text); | 8142 textlen = (int)strlen(text); |
8095 | 8143 |
8096 if(flags & DW_MLE_CASESENSITIVE) | 8144 if(flags & DW_MLE_CASESENSITIVE) |
8097 { | 8145 { |
8098 for(z=point;z<(len-textlen) && !retval;z++) | 8146 for(z=point;z<(len-textlen) && !retval;z++) |
8099 { | 8147 { |
8100 if(strncmp(&tmpbuf[z], text, textlen) == 0) | 8148 if(_tcsncmp(&tmpbuf[z], searchtext, textlen) == 0) |
8101 retval = z + textlen; | 8149 retval = z + textlen; |
8102 } | 8150 } |
8103 } | 8151 } |
8104 else | 8152 else |
8105 { | 8153 { |
8106 for(z=point;z<(len-textlen) && !retval;z++) | 8154 for(z=point;z<(len-textlen) && !retval;z++) |
8107 { | 8155 { |
8108 if(_strnicmp(&tmpbuf[z], text, textlen) == 0) | 8156 if(_tcsnicmp(&tmpbuf[z], searchtext, textlen) == 0) |
8109 retval = z + textlen; | 8157 retval = z + textlen; |
8110 } | 8158 } |
8111 } | 8159 } |
8112 | 8160 |
8113 if(retval) | 8161 if(retval) |
8258 * handle: Handle to the spinbutton to be set. | 8306 * handle: Handle to the spinbutton to be set. |
8259 * position: Current value of the spinbutton. | 8307 * position: Current value of the spinbutton. |
8260 */ | 8308 */ |
8261 void API dw_spinbutton_set_pos(HWND handle, long position) | 8309 void API dw_spinbutton_set_pos(HWND handle, long position) |
8262 { | 8310 { |
8263 char tmpbuf[101] = {0}; | 8311 TCHAR tmpbuf[101] = {0}; |
8264 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 8312 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
8265 | 8313 |
8266 _snprintf(tmpbuf, 100, "%ld", position); | 8314 _sntprintf(tmpbuf, 100, TEXT("%ld"), position); |
8267 | 8315 |
8268 if(cinfo && cinfo->buddy) | 8316 if(cinfo && cinfo->buddy) |
8269 SetWindowText(cinfo->buddy, tmpbuf); | 8317 SetWindowText(cinfo->buddy, tmpbuf); |
8270 | 8318 |
8271 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position); | 8319 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position); |
8317 } | 8365 } |
8318 | 8366 |
8319 /* This function unchecks all radiobuttons on a box */ | 8367 /* This function unchecks all radiobuttons on a box */ |
8320 BOOL CALLBACK _uncheck_radios(HWND handle, LPARAM lParam) | 8368 BOOL CALLBACK _uncheck_radios(HWND handle, LPARAM lParam) |
8321 { | 8369 { |
8322 char tmpbuf[100] = {0}; | 8370 TCHAR tmpbuf[100] = {0}; |
8323 | 8371 |
8324 GetClassName(handle, tmpbuf, 99); | 8372 GetClassName(handle, tmpbuf, 99); |
8325 | 8373 |
8326 if(_strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0) | 8374 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0) |
8327 { | 8375 { |
8328 if(!dw_window_get_data(handle, "_dw_checkbox")) | 8376 if(!dw_window_get_data(handle, "_dw_checkbox")) |
8329 SendMessage(handle, BM_SETCHECK, 0, 0); | 8377 SendMessage(handle, BM_SETCHECK, 0, 0); |
8330 } | 8378 } |
8331 return TRUE; | 8379 return TRUE; |
8367 | 8415 |
8368 ptrs[0] = title; | 8416 ptrs[0] = title; |
8369 ptrs[1] = itemdata; | 8417 ptrs[1] = itemdata; |
8370 | 8418 |
8371 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; | 8419 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; |
8372 tvi.pszText = title; | 8420 tvi.pszText = UTF8toWide(title); |
8373 tvi.lParam = (LONG)ptrs; | 8421 tvi.lParam = (LONG)ptrs; |
8374 tvi.cchTextMax = (int)strlen(title); | 8422 tvi.cchTextMax = (int)_tcslen(tvi.pszText); |
8375 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); | 8423 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); |
8376 | 8424 |
8377 tvins.item = tvi; | 8425 tvins.item = tvi; |
8378 tvins.hParent = parent; | 8426 tvins.hParent = parent; |
8379 tvins.hInsertAfter = item ? item : TVI_FIRST; | 8427 tvins.hInsertAfter = item ? item : TVI_FIRST; |
8401 | 8449 |
8402 ptrs[0] = title; | 8450 ptrs[0] = title; |
8403 ptrs[1] = itemdata; | 8451 ptrs[1] = itemdata; |
8404 | 8452 |
8405 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; | 8453 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; |
8406 tvi.pszText = title; | 8454 tvi.pszText = UTF8toWide(title); |
8407 tvi.lParam = (LONG)ptrs; | 8455 tvi.lParam = (LONG)ptrs; |
8408 tvi.cchTextMax = (int)strlen(title); | 8456 tvi.cchTextMax = (int)_tcslen(tvi.pszText); |
8409 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); | 8457 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); |
8410 | 8458 |
8411 tvins.item = tvi; | 8459 tvins.item = tvi; |
8412 tvins.hParent = parent; | 8460 tvins.hParent = parent; |
8413 tvins.hInsertAfter = TVI_LAST; | 8461 tvins.hInsertAfter = TVI_LAST; |
8438 | 8486 |
8439 ptrs = (void **)tvi.lParam; | 8487 ptrs = (void **)tvi.lParam; |
8440 ptrs[0] = title; | 8488 ptrs[0] = title; |
8441 | 8489 |
8442 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; | 8490 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; |
8443 tvi.pszText = title; | 8491 tvi.pszText = UTF8toWide(title); |
8444 tvi.cchTextMax = (int)strlen(title); | 8492 tvi.cchTextMax = (int)_tcslen(tvi.pszText); |
8445 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); | 8493 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); |
8446 tvi.hItem = (HTREEITEM)item; | 8494 tvi.hItem = (HTREEITEM)item; |
8447 | 8495 |
8448 TreeView_SetItem(handle, &tvi); | 8496 TreeView_SetItem(handle, &tvi); |
8449 } | 8497 } |
8505 | 8553 |
8506 tvi.mask = TVIF_HANDLE; | 8554 tvi.mask = TVIF_HANDLE; |
8507 tvi.hItem = item; | 8555 tvi.hItem = item; |
8508 | 8556 |
8509 if(TreeView_GetItem(handle, &tvi)) | 8557 if(TreeView_GetItem(handle, &tvi)) |
8510 return tvi.pszText; | 8558 return strdup(WideToUTF8(tvi.pszText)); |
8511 return NULL; | 8559 return NULL; |
8512 } | 8560 } |
8513 | 8561 |
8514 /* | 8562 /* |
8515 * Gets the text an item in a tree window (widget). | 8563 * Gets the text an item in a tree window (widget). |
8652 for(z=0;z<count;z++) | 8700 for(z=0;z<count;z++) |
8653 { | 8701 { |
8654 if(titles[z]) | 8702 if(titles[z]) |
8655 { | 8703 { |
8656 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_FMT; | 8704 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_FMT; |
8657 lvc.pszText = titles[z]; | 8705 lvc.pszText = UTF8toWide(titles[z]); |
8658 lvc.cchTextMax = (int)strlen(titles[z]); | 8706 lvc.cchTextMax = (int)_tcslen(lvc.pszText); |
8659 if(flags[z] & DW_CFA_RIGHT) | 8707 if(flags[z] & DW_CFA_RIGHT) |
8660 lvc.fmt = LVCFMT_RIGHT; | 8708 lvc.fmt = LVCFMT_RIGHT; |
8661 else if(flags[z] & DW_CFA_CENTER) | 8709 else if(flags[z] & DW_CFA_CENTER) |
8662 lvc.fmt = LVCFMT_CENTER; | 8710 lvc.fmt = LVCFMT_CENTER; |
8663 else | 8711 else |
8682 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | 8730 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) |
8683 { | 8731 { |
8684 LV_COLUMN lvc; | 8732 LV_COLUMN lvc; |
8685 | 8733 |
8686 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; | 8734 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; |
8687 lvc.pszText = "Filename"; | 8735 lvc.pszText = TEXT("Filename"); |
8688 lvc.cchTextMax = 8; | 8736 lvc.cchTextMax = 8; |
8689 lvc.fmt = 0; | 8737 lvc.fmt = 0; |
8690 if(!count) | 8738 if(!count) |
8691 lvc.cx = 300; | 8739 lvc.cx = 300; |
8692 else | 8740 else |
8811 | 8859 |
8812 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT | LVIF_IMAGE; | 8860 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT | LVIF_IMAGE; |
8813 lvi.iSubItem = 0; | 8861 lvi.iSubItem = 0; |
8814 /* Insert at the end */ | 8862 /* Insert at the end */ |
8815 lvi.iItem = 1000000; | 8863 lvi.iItem = 1000000; |
8816 lvi.pszText = ""; | 8864 lvi.pszText = TEXT(""); |
8817 lvi.cchTextMax = 1; | 8865 lvi.cchTextMax = 1; |
8818 lvi.iImage = -1; | 8866 lvi.iImage = -1; |
8819 | 8867 |
8820 ShowWindow(handle, SW_HIDE); | 8868 ShowWindow(handle, SW_HIDE); |
8821 item = ListView_InsertItem(handle, &lvi); | 8869 item = ListView_InsertItem(handle, &lvi); |
8904 } | 8952 } |
8905 | 8953 |
8906 lvi.iItem = row + item; | 8954 lvi.iItem = row + item; |
8907 lvi.iSubItem = 0; | 8955 lvi.iSubItem = 0; |
8908 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT; | 8956 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT; |
8909 lvi.pszText = filename; | 8957 lvi.pszText = UTF8toWide(filename); |
8910 lvi.cchTextMax = (int)strlen(filename); | 8958 lvi.cchTextMax = (int)_tcslen(lvi.pszText); |
8911 lvi.iImage = _lookup_icon(handle, (HICON)icon, 0); | 8959 lvi.iImage = _lookup_icon(handle, (HICON)icon, 0); |
8912 | 8960 |
8913 ListView_SetItem(handle, &lvi); | 8961 ListView_SetItem(handle, &lvi); |
8914 } | 8962 } |
8915 | 8963 |
8939 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | 8987 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) |
8940 { | 8988 { |
8941 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 8989 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
8942 ULONG *flags; | 8990 ULONG *flags; |
8943 LV_ITEM lvi; | 8991 LV_ITEM lvi; |
8944 char textbuffer[101] = {0}; | 8992 TCHAR textbuffer[101] = {0}; |
8945 int item = 0; | 8993 int item = 0; |
8946 | 8994 |
8947 if(pointer) | 8995 if(pointer) |
8948 { | 8996 { |
8949 item = (int)dw_window_get_data(handle, "_dw_insertitem"); | 8997 item = (int)dw_window_get_data(handle, "_dw_insertitem"); |
8979 char *tmp = *((char **)data); | 9027 char *tmp = *((char **)data); |
8980 | 9028 |
8981 if(!tmp) | 9029 if(!tmp) |
8982 tmp = ""; | 9030 tmp = ""; |
8983 | 9031 |
8984 lvi.pszText = tmp; | 9032 lvi.pszText = UTF8toWide(tmp); |
8985 lvi.cchTextMax = (int)strlen(tmp); | 9033 lvi.cchTextMax = (int)_tcslen(lvi.pszText); |
8986 } | 9034 } |
8987 else if(flags[column] & DW_CFA_ULONG && data) | 9035 else if(flags[column] & DW_CFA_ULONG && data) |
8988 { | 9036 { |
8989 ULONG tmp = *((ULONG *)data); | 9037 ULONG tmp = *((ULONG *)data); |
8990 | 9038 |
8991 _snprintf(textbuffer, 100, "%lu", tmp); | 9039 _sntprintf(textbuffer, 100, TEXT("%lu"), tmp); |
8992 | 9040 |
8993 lvi.cchTextMax = (int)strlen(textbuffer); | 9041 lvi.cchTextMax = (int)_tcslen(textbuffer); |
8994 } | 9042 } |
8995 else if(flags[column] & DW_CFA_DATE && data) | 9043 else if(flags[column] & DW_CFA_DATE && data) |
8996 { | 9044 { |
8997 struct tm curtm; | 9045 struct tm curtm; |
8998 CDATE cdate = *((CDATE *)data); | 9046 CDATE cdate = *((CDATE *)data); |
9005 if(cdate.year > 1900 && cdate.year < 2100) | 9053 if(cdate.year > 1900 && cdate.year < 2100) |
9006 { | 9054 { |
9007 curtm.tm_mday = (cdate.day >= 0 && cdate.day < 32) ? cdate.day : 1; | 9055 curtm.tm_mday = (cdate.day >= 0 && cdate.day < 32) ? cdate.day : 1; |
9008 curtm.tm_mon = (cdate.month > 0 && cdate.month < 13) ? cdate.month - 1 : 0; | 9056 curtm.tm_mon = (cdate.month > 0 && cdate.month < 13) ? cdate.month - 1 : 0; |
9009 curtm.tm_year = cdate.year - 1900; | 9057 curtm.tm_year = cdate.year - 1900; |
9010 strftime(textbuffer, 100, "%x", &curtm); | 9058 _tcsftime(textbuffer, 100, TEXT("%x"), &curtm); |
9011 } | 9059 } |
9012 | 9060 |
9013 lvi.cchTextMax = (int)strlen(textbuffer); | 9061 lvi.cchTextMax = (int)_tcslen(textbuffer); |
9014 } | 9062 } |
9015 else if(flags[column] & DW_CFA_TIME && data) | 9063 else if(flags[column] & DW_CFA_TIME && data) |
9016 { | 9064 { |
9017 struct tm curtm; | 9065 struct tm curtm; |
9018 CTIME ctime = *((CTIME *)data); | 9066 CTIME ctime = *((CTIME *)data); |
9019 | 9067 |
9020 curtm.tm_hour = (ctime.hours >= 0 && ctime.hours < 24) ? ctime.hours : 0; | 9068 curtm.tm_hour = (ctime.hours >= 0 && ctime.hours < 24) ? ctime.hours : 0; |
9021 curtm.tm_min = (ctime.minutes >= 0 && ctime.minutes < 60) ? ctime.minutes : 0; | 9069 curtm.tm_min = (ctime.minutes >= 0 && ctime.minutes < 60) ? ctime.minutes : 0; |
9022 curtm.tm_sec = (ctime.seconds >= 0 && ctime.seconds < 60) ? ctime.seconds : 0; | 9070 curtm.tm_sec = (ctime.seconds >= 0 && ctime.seconds < 60) ? ctime.seconds : 0; |
9023 | 9071 |
9024 strftime(textbuffer, 100, "%X", &curtm); | 9072 _tcsftime(textbuffer, 100, TEXT("%X"), &curtm); |
9025 | 9073 |
9026 lvi.cchTextMax = (int)strlen(textbuffer); | 9074 lvi.cchTextMax = (int)_tcslen(textbuffer); |
9027 } | 9075 } |
9028 | 9076 |
9029 ListView_SetItem(handle, &lvi); | 9077 ListView_SetItem(handle, &lvi); |
9030 } | 9078 } |
9031 | 9079 |
9410 ListView_SetColumnWidth(handle, 0, LVSCW_AUTOSIZE); | 9458 ListView_SetColumnWidth(handle, 0, LVSCW_AUTOSIZE); |
9411 } | 9459 } |
9412 else if(cinfo && cinfo->columns > 1) | 9460 else if(cinfo && cinfo->columns > 1) |
9413 { | 9461 { |
9414 ULONG *flags = cinfo->flags, *columns = calloc(sizeof(ULONG), cinfo->columns); | 9462 ULONG *flags = cinfo->flags, *columns = calloc(sizeof(ULONG), cinfo->columns); |
9415 char *text = malloc(1024); | 9463 TCHAR *text = calloc(sizeof(TCHAR), 1024); |
9416 unsigned int z; | 9464 unsigned int z; |
9417 int index; | 9465 int index; |
9418 | 9466 |
9419 /* Initialize with sizes of column labels */ | 9467 /* Initialize with sizes of column labels */ |
9420 for(z=0;z<cinfo->columns;z++) | 9468 for(z=0;z<cinfo->columns;z++) |
9488 tnid.uID = (UINT)icon; | 9536 tnid.uID = (UINT)icon; |
9489 tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; | 9537 tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
9490 tnid.uCallbackMessage = WM_USER+2; | 9538 tnid.uCallbackMessage = WM_USER+2; |
9491 tnid.hIcon = (HICON)icon; | 9539 tnid.hIcon = (HICON)icon; |
9492 if(bubbletext) | 9540 if(bubbletext) |
9493 strncpy(tnid.szTip, bubbletext, sizeof(tnid.szTip)); | 9541 _tcsncpy(tnid.szTip, UTF8toWide(bubbletext), sizeof(tnid.szTip)); |
9494 else | 9542 else |
9495 tnid.szTip[0] = 0; | 9543 tnid.szTip[0] = 0; |
9496 | 9544 |
9497 Shell_NotifyIcon(NIM_ADD, &tnid); | 9545 Shell_NotifyIcon(NIM_ADD, &tnid); |
9498 } | 9546 } |
9848 HDC hdc; | 9896 HDC hdc; |
9849 int mustdelete = 0; | 9897 int mustdelete = 0; |
9850 HFONT hFont = 0, oldFont = 0; | 9898 HFONT hFont = 0, oldFont = 0; |
9851 ColorInfo *cinfo = NULL; | 9899 ColorInfo *cinfo = NULL; |
9852 COLORREF background; | 9900 COLORREF background; |
9901 TCHAR *wtext = UTF8toWide(text); | |
9853 | 9902 |
9854 if(handle) | 9903 if(handle) |
9855 hdc = GetDC(handle); | 9904 hdc = GetDC(handle); |
9856 else if(pixmap) | 9905 else if(pixmap) |
9857 hdc = pixmap->hdc; | 9906 hdc = pixmap->hdc; |
9880 else | 9929 else |
9881 { | 9930 { |
9882 SetBkMode(hdc, OPAQUE); | 9931 SetBkMode(hdc, OPAQUE); |
9883 SetBkColor(hdc, background); | 9932 SetBkColor(hdc, background); |
9884 } | 9933 } |
9885 TextOut(hdc, x, y, text, (int)strlen(text)); | 9934 TextOut(hdc, x, y, wtext, (int)_tcslen(wtext)); |
9886 if(oldFont) | 9935 if(oldFont) |
9887 SelectObject(hdc, oldFont); | 9936 SelectObject(hdc, oldFont); |
9888 if(mustdelete) | 9937 if(mustdelete) |
9889 DeleteObject(hFont); | 9938 DeleteObject(hFont); |
9890 if(!pixmap) | 9939 if(!pixmap) |
9903 { | 9952 { |
9904 HDC hdc; | 9953 HDC hdc; |
9905 int mustdelete = 0; | 9954 int mustdelete = 0; |
9906 HFONT hFont = NULL, oldFont; | 9955 HFONT hFont = NULL, oldFont; |
9907 SIZE sz; | 9956 SIZE sz; |
9957 TCHAR *wtext = UTF8toWide(text); | |
9908 | 9958 |
9909 if(handle) | 9959 if(handle) |
9910 hdc = GetDC(handle); | 9960 hdc = GetDC(handle); |
9911 else if(pixmap) | 9961 else if(pixmap) |
9912 hdc = pixmap->hdc; | 9962 hdc = pixmap->hdc; |
9932 mustdelete = 1; | 9982 mustdelete = 1; |
9933 } | 9983 } |
9934 } | 9984 } |
9935 oldFont = SelectObject(hdc, hFont); | 9985 oldFont = SelectObject(hdc, hFont); |
9936 | 9986 |
9937 GetTextExtentPoint32(hdc, text, (int)strlen(text), &sz); | 9987 GetTextExtentPoint32(hdc, wtext, (int)_tcslen(wtext), &sz); |
9938 | 9988 |
9939 if(width) | 9989 if(width) |
9940 *width = sz.cx; | 9990 *width = sz.cx; |
9941 | 9991 |
9942 if(height) | 9992 if(height) |
10407 int API dw_module_load(char *name, HMOD *handle) | 10457 int API dw_module_load(char *name, HMOD *handle) |
10408 { | 10458 { |
10409 if(!handle) | 10459 if(!handle) |
10410 return DW_ERROR_UNKNOWN; | 10460 return DW_ERROR_UNKNOWN; |
10411 | 10461 |
10412 *handle = LoadLibrary(name); | 10462 *handle = LoadLibrary(UTF8toWide(name)); |
10413 return (NULL == *handle); | 10463 return (NULL == *handle); |
10414 } | 10464 } |
10415 | 10465 |
10416 /* Queries the address of a symbol within open handle. | 10466 /* Queries the address of a symbol within open handle. |
10417 * Parameters: | 10467 * Parameters: |
10582 | 10632 |
10583 sa.nLength = sizeof( SECURITY_ATTRIBUTES); | 10633 sa.nLength = sizeof( SECURITY_ATTRIBUTES); |
10584 sa.lpSecurityDescriptor = &_dwsd; | 10634 sa.lpSecurityDescriptor = &_dwsd; |
10585 sa.bInheritHandle = FALSE; | 10635 sa.bInheritHandle = FALSE; |
10586 | 10636 |
10587 return CreateEvent(&sa, TRUE, FALSE, name); | 10637 return CreateEvent(&sa, TRUE, FALSE, UTF8toWide(name)); |
10588 } | 10638 } |
10589 | 10639 |
10590 /* Destroy this semaphore. | 10640 /* Destroy this semaphore. |
10591 * Parameters: | 10641 * Parameters: |
10592 * eve: Handle to the semaphore obtained by | 10642 * eve: Handle to the semaphore obtained by |
10593 * a create call. | 10643 * a create call. |
10594 */ | 10644 */ |
10595 HEV API dw_named_event_get(char *name) | 10645 HEV API dw_named_event_get(char *name) |
10596 { | 10646 { |
10597 return OpenEvent(EVENT_ALL_ACCESS, FALSE, name); | 10647 return OpenEvent(EVENT_ALL_ACCESS, FALSE, UTF8toWide(name)); |
10598 } | 10648 } |
10599 | 10649 |
10600 /* Resets the event semaphore so threads who call wait | 10650 /* Resets the event semaphore so threads who call wait |
10601 * on this semaphore will block. | 10651 * on this semaphore will block. |
10602 * Parameters: | 10652 * Parameters: |
10673 | 10723 |
10674 sa.nLength = sizeof(SECURITY_ATTRIBUTES); | 10724 sa.nLength = sizeof(SECURITY_ATTRIBUTES); |
10675 sa.lpSecurityDescriptor = &_dwsd; | 10725 sa.lpSecurityDescriptor = &_dwsd; |
10676 sa.bInheritHandle = FALSE; | 10726 sa.bInheritHandle = FALSE; |
10677 | 10727 |
10678 handle = CreateFileMapping((HANDLE)0xFFFFFFFF, &sa, PAGE_READWRITE, 0, size, name); | 10728 handle = CreateFileMapping((HANDLE)0xFFFFFFFF, &sa, PAGE_READWRITE, 0, size, UTF8toWide(name)); |
10679 | 10729 |
10680 if(!handle) | 10730 if(!handle) |
10681 return 0; | 10731 return 0; |
10682 | 10732 |
10683 *dest = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, 0); | 10733 *dest = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, 0); |
10698 * size: Size in bytes of the shared memory region to requested. | 10748 * size: Size in bytes of the shared memory region to requested. |
10699 * name: A string pointer to a unique memory name. | 10749 * name: A string pointer to a unique memory name. |
10700 */ | 10750 */ |
10701 HSHM API dw_named_memory_get(void **dest, int size, char *name) | 10751 HSHM API dw_named_memory_get(void **dest, int size, char *name) |
10702 { | 10752 { |
10703 HSHM handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, name); | 10753 HSHM handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, UTF8toWide(name)); |
10704 | 10754 |
10705 if(!handle) | 10755 if(!handle) |
10706 return 0; | 10756 return 0; |
10707 | 10757 |
10708 *dest = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, 0); | 10758 *dest = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, 0); |
11203 } | 11253 } |
11204 #endif | 11254 #endif |
11205 } | 11255 } |
11206 else | 11256 else |
11207 { | 11257 { |
11208 DWORD att = defpath ? GetFileAttributes(defpath) : INVALID_FILE_ATTRIBUTES; | 11258 DWORD att = defpath ? GetFileAttributes(UTF8toWide(defpath)) : INVALID_FILE_ATTRIBUTES; |
11209 | 11259 |
11210 if (ext) | 11260 if (ext) |
11211 { | 11261 { |
11212 /* | 11262 /* |
11213 * The following mess is because sprintf() trunates at first \0 | 11263 * The following mess is because sprintf() trunates at first \0 |
11228 memset( &of, 0, sizeof(OPENFILENAME) ); | 11278 memset( &of, 0, sizeof(OPENFILENAME) ); |
11229 | 11279 |
11230 of.lStructSize = sizeof(OPENFILENAME); | 11280 of.lStructSize = sizeof(OPENFILENAME); |
11231 of.hwndOwner = HWND_DESKTOP; | 11281 of.hwndOwner = HWND_DESKTOP; |
11232 of.hInstance = DWInstance; | 11282 of.hInstance = DWInstance; |
11233 of.lpstrTitle = title; | 11283 of.lpstrTitle = UTF8toWide(title); |
11234 of.lpstrInitialDir = "."; | 11284 of.lpstrInitialDir = TEXT("."); |
11235 if(att != INVALID_FILE_ATTRIBUTES && (att & FILE_ATTRIBUTE_DIRECTORY)) | 11285 if(att != INVALID_FILE_ATTRIBUTES && (att & FILE_ATTRIBUTE_DIRECTORY)) |
11236 of.lpstrInitialDir = defpath; | 11286 of.lpstrInitialDir = UTF8toWide(defpath); |
11237 else if(defpath) | 11287 else if(defpath) |
11238 _to_dos(filenamebuf, defpath); | 11288 _to_dos(filenamebuf, defpath); |
11239 of.lpstrFile = filenamebuf; | 11289 of.lpstrFile = UTF8toWide(filenamebuf); |
11240 of.lpstrFilter = filterbuf; | 11290 of.lpstrFilter = UTF8toWide(filterbuf); |
11241 of.nFilterIndex = 1; | 11291 of.nFilterIndex = 1; |
11242 of.nMaxFile = 1000; | 11292 of.nMaxFile = 1000; |
11243 /*of.lpstrDefExt = ext;*/ | 11293 /*of.lpstrDefExt = ext;*/ |
11244 of.Flags = OFN_NOCHANGEDIR; | 11294 of.Flags = OFN_NOCHANGEDIR; |
11245 | 11295 |
11253 of.Flags |= OFN_FILEMUSTEXIST; | 11303 of.Flags |= OFN_FILEMUSTEXIST; |
11254 rc = GetOpenFileName(&of); | 11304 rc = GetOpenFileName(&of); |
11255 } | 11305 } |
11256 | 11306 |
11257 if (rc) | 11307 if (rc) |
11258 return _strdup(of.lpstrFile); | 11308 return _strdup(WideToUTF8(of.lpstrFile)); |
11259 } | 11309 } |
11260 return NULL; | 11310 return NULL; |
11261 } | 11311 } |
11262 | 11312 |
11263 /* | 11313 /* |
11326 if(browseurl[z] == '/') | 11376 if(browseurl[z] == '/') |
11327 browseurl[z] = '\\'; | 11377 browseurl[z] = '\\'; |
11328 } | 11378 } |
11329 } | 11379 } |
11330 | 11380 |
11331 retcode = (int)ShellExecute(NULL, "open", browseurl, NULL, NULL, SW_SHOWNORMAL); | 11381 retcode = (int)ShellExecute(NULL, TEXT("open"), UTF8toWide(browseurl), NULL, NULL, SW_SHOWNORMAL); |
11332 if(retcode<33 && retcode != 2) | 11382 if(retcode<33 && retcode != 2) |
11333 return DW_ERROR_UNKNOWN; | 11383 return DW_ERROR_UNKNOWN; |
11334 return DW_ERROR_NONE; | 11384 return DW_ERROR_NONE; |
11335 } | 11385 } |
11336 | 11386 |
11377 free(print); | 11427 free(print); |
11378 return NULL; | 11428 return NULL; |
11379 } | 11429 } |
11380 | 11430 |
11381 print->di.cbSize = sizeof(DOCINFO); | 11431 print->di.cbSize = sizeof(DOCINFO); |
11382 print->di.lpszDocName = jobname ? jobname : "Dynamic Windows Print Job"; | 11432 print->di.lpszDocName = jobname ? UTF8toWide(jobname) : TEXT("Dynamic Windows Print Job"); |
11383 return print; | 11433 return print; |
11384 } | 11434 } |
11385 | 11435 |
11386 /* | 11436 /* |
11387 * Runs the print job, causing the draw page callbacks to fire. | 11437 * Runs the print job, causing the draw page callbacks to fire. |
11463 | 11513 |
11464 /* Use the Windows API to get the user's profile directory */ | 11514 /* Use the Windows API to get the user's profile directory */ |
11465 if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) | 11515 if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) |
11466 { | 11516 { |
11467 DWORD BufSize = 1024; | 11517 DWORD BufSize = 1024; |
11468 | 11518 TCHAR Buf[1024]; |
11469 GetUserProfileDirectory(hToken, _user_dir, &BufSize); | 11519 |
11520 GetUserProfileDirectory(hToken, Buf, &BufSize); | |
11470 CloseHandle(hToken); | 11521 CloseHandle(hToken); |
11522 strncpy(_user_dir, WideToUTF8(Buf), 1023); | |
11471 } | 11523 } |
11472 /* If it fails set it to the root directory */ | 11524 /* If it fails set it to the root directory */ |
11473 if(!_user_dir[0]) | 11525 if(!_user_dir[0]) |
11474 { | 11526 { |
11475 strcpy(_user_dir, "C:\\"); | 11527 strcpy(_user_dir, "C:\\"); |