35 |
#include "wptW32API.h" |
#include "wptW32API.h" |
36 |
#include "wptErrors.h" |
#include "wptErrors.h" |
37 |
#include "wptVersion.h" |
#include "wptVersion.h" |
38 |
|
#include "wptUTF8.h" |
39 |
#include "wptTypes.h" |
#include "wptTypes.h" |
40 |
|
|
41 |
|
|
42 |
extern "C" void _SHFree (void *p); |
extern "C" void _SHFree (void *p); |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
/* Insert a new item into the menu @hm at position @pos. */ |
47 |
|
void |
48 |
|
insert_menu_item (HMENU hm, int pos, UINT m_id, const char *text) |
49 |
|
{ |
50 |
|
MENUITEMINFO mi; |
51 |
|
|
52 |
|
memset (&mi, 0, sizeof mi); |
53 |
|
mi.cbSize = sizeof mi; |
54 |
|
mi.fType = MF_STRING; |
55 |
|
mi.dwTypeData = (char *)text; |
56 |
|
mi.cch = strlen (text); |
57 |
|
mi.wID = m_id; |
58 |
|
mi.fMask = MIIM_ID|MIIM_DATA| MIIM_TYPE; |
59 |
|
InsertMenuItem (hm, pos, FALSE, &mi); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
static void |
static void |
64 |
set_menu_text_ext (HMENU menu, int by_pos, int m_uid, const char *text) |
set_menu_text_ext (HMENU menu, int by_pos, int m_uid, const char *text) |
65 |
{ |
{ |
127 |
id can be either FILE_OPEN or FILE_SAVE. |
id can be either FILE_OPEN or FILE_SAVE. |
128 |
The return value is the file name or NULL if cancel was chosen. */ |
The return value is the file name or NULL if cancel was chosen. */ |
129 |
const char * |
const char * |
130 |
get_filename_dlg (HWND hwnd, int id, const char * title, |
get_filename_dlg (HWND hwnd, int id, const char *title, |
131 |
const char * filter, const char * name) |
const char *filter, const char *name) |
132 |
{ |
{ |
133 |
static char file[512] = ""; |
static char file[512] = ""; |
134 |
OPENFILENAME open; |
OPENFILENAME open; |
257 |
BUG (NULL); |
BUG (NULL); |
258 |
p = (char *) GlobalLock (clipmem); |
p = (char *) GlobalLock (clipmem); |
259 |
if (p == NULL) { |
if (p == NULL) { |
260 |
rc = WPTERR_GENERAL;; |
CloseClipboard (); |
261 |
goto leave; |
GlobalFree (clipmem); |
262 |
|
return WPTERR_GENERAL; |
263 |
} |
} |
264 |
memcpy (p, text, nbytes); |
memcpy (p, text, nbytes); |
265 |
p[nbytes] = '\0'; |
p[nbytes] = '\0'; |
266 |
|
|
|
GlobalUnlock (clipmem); |
|
267 |
SetClipboardData (CF_TEXT, clipmem); |
SetClipboardData (CF_TEXT, clipmem); |
268 |
|
GlobalUnlock (clipmem); |
269 |
|
CloseClipboard (); |
270 |
GlobalFree (clipmem); |
GlobalFree (clipmem); |
271 |
|
|
|
leave: |
|
|
CloseClipboard (); |
|
272 |
return rc; |
return rc; |
273 |
} |
} |
274 |
|
|
591 |
} |
} |
592 |
|
|
593 |
|
|
594 |
|
/* SetDlgItemText replacement with UTF8 support. */ |
595 |
|
void |
596 |
|
SetDlgItemText_utf8 (HWND dlg, int id, const char *txt) |
597 |
|
{ |
598 |
|
char *utf8_txt; |
599 |
|
|
600 |
|
utf8_txt = utf8_to_native (txt); |
601 |
|
SetDlgItemText (dlg, id, utf8_txt); |
602 |
|
safe_free (utf8_txt); |
603 |
|
} |
604 |
|
|
605 |
|
/* SetWindowText replacement with UTF8 support. */ |
606 |
|
void |
607 |
|
SetWindowText_utf8 (HWND hwnd, const char *txt) |
608 |
|
{ |
609 |
|
char *utf8_txt; |
610 |
|
|
611 |
|
utf8_txt = utf8_to_native (txt); |
612 |
|
SetWindowText (hwnd, utf8_txt); |
613 |
|
safe_free (utf8_txt); |
614 |
|
} |
615 |
|
|
616 |
|
|
617 |
|
void |
618 |
|
ListBox_AddString_utf8 (HWND lb, const char *txt) |
619 |
|
{ |
620 |
|
char *utf8_txt; |
621 |
|
|
622 |
|
utf8_txt = utf8_to_native (txt); |
623 |
|
SendMessage (lb, LB_ADDSTRING, 0, (LPARAM)(LPCSTR)(utf8_txt)); |
624 |
|
safe_free (utf8_txt); |
625 |
|
} |
626 |
|
|
627 |
|
|
628 |
|
void |
629 |
|
ComboBox_AddString_utf8 (HWND cb, const char *txt) |
630 |
|
{ |
631 |
|
|
632 |
|
char *utf8_txt; |
633 |
|
|
634 |
|
utf8_txt = utf8_to_native (txt); |
635 |
|
SendMessage ((cb), CB_ADDSTRING, 0, (LPARAM)(LPCSTR)(utf8_txt)); |
636 |
|
safe_free (utf8_txt); |
637 |
|
} |
638 |
|
|
639 |
|
|
640 |
|
/* GetDlgItemText replacement with UTF8 support. */ |
641 |
|
int |
642 |
|
GetDlgItemText_utf8 (HWND dlg, int id, char **r_txt) |
643 |
|
{ |
644 |
|
int len = GetWindowTextLength (GetDlgItem (dlg, id)); |
645 |
|
char *txt; |
646 |
|
|
647 |
|
*r_txt = NULL; |
648 |
|
if (len < 1) |
649 |
|
return 0; |
650 |
|
txt = new char[len+2]; |
651 |
|
if (!txt) |
652 |
|
BUG (NULL); |
653 |
|
GetDlgItemText (dlg, id, txt, len+1); |
654 |
|
*r_txt = native_to_utf8 (txt); |
655 |
|
free_if_alloc (txt); |
656 |
|
return len; |
657 |
|
} |
658 |
|
|
659 |
|
|
660 |
struct reminder_hd_s { |
struct reminder_hd_s { |
661 |
int msecs; |
int msecs; |
662 |
HWND dlg; |
HWND dlg; |