29 |
#include <shellapi.h> |
#include <shellapi.h> |
30 |
#include <shlobj.h> |
#include <shlobj.h> |
31 |
#include <commctrl.h> |
#include <commctrl.h> |
32 |
|
#include <time.h> |
33 |
|
|
34 |
#include "wptNLS.h" |
#include "wptNLS.h" |
35 |
#include "wptW32API.h" |
#include "wptW32API.h" |
57 |
|
|
58 |
/* Set the text of a menu item @m_uid to @text. */ |
/* Set the text of a menu item @m_uid to @text. */ |
59 |
void |
void |
60 |
set_menu_text (HMENU menu, int m_uid, const char *text) |
set_menu_text (HMENU menu, UINT m_uid, const char *text) |
61 |
{ |
{ |
62 |
set_menu_text_ext (menu, 0, m_uid, text); |
set_menu_text_ext (menu, 0, m_uid, text); |
63 |
} |
} |
65 |
|
|
66 |
/* Set the text of a menu item with the position @pos to @text. */ |
/* Set the text of a menu item with the position @pos to @text. */ |
67 |
void |
void |
68 |
set_menu_text_bypos (HMENU menu, int pos, const char *text) |
set_menu_text_bypos (HMENU menu, UINT pos, const char *text) |
69 |
{ |
{ |
70 |
set_menu_text_ext (menu, 1, pos, text); |
set_menu_text_ext (menu, 1, pos, text); |
71 |
} |
} |
73 |
|
|
74 |
/* Set the state of a menu item @m_uid to @state. */ |
/* Set the state of a menu item @m_uid to @state. */ |
75 |
void |
void |
76 |
set_menu_state (HMENU menu, int m_uid, int state) |
set_menu_state (HMENU menu, UINT m_uid, UINT state) |
77 |
{ |
{ |
78 |
MENUITEMINFO mii; |
MENUITEMINFO mii; |
79 |
|
|
85 |
} |
} |
86 |
|
|
87 |
|
|
88 |
|
/* Retrieve the state of the menu item @m_uid and return it. */ |
89 |
|
UINT |
90 |
|
get_menu_state (HMENU menu, UINT m_uid) |
91 |
|
{ |
92 |
|
MENUITEMINFO mii; |
93 |
|
|
94 |
|
memset (&mii, 0, sizeof (mii)); |
95 |
|
mii.cbSize = sizeof (mii); |
96 |
|
mii.fMask = MIIM_STATE; |
97 |
|
GetMenuItemInfo (menu, m_uid, FALSE, &mii); |
98 |
|
return mii.fState; |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
enum { |
enum { |
103 |
CDLG_FILE_OPEN = 0, |
CDLG_FILE_OPEN = 0, |
104 |
CDLG_FILE_SAVE = 1 |
CDLG_FILE_SAVE = 1 |
517 |
} |
} |
518 |
|
|
519 |
|
|
520 |
void |
/* Return date in a format which complies with the |
521 |
set_active_window( HWND dlg) |
system locale settings. */ |
522 |
{ |
const char* |
523 |
activ_hwnd = dlg; |
get_locale_date (long tm_t, char *buf, DWORD buflen) |
524 |
} /* set_active_window */ |
{ |
525 |
|
SYSTEMTIME st; |
526 |
void |
struct tm *ptm; |
527 |
reset_active_window( void ) |
|
528 |
{ |
ptm = localtime (&tm_t); |
529 |
activ_hwnd = NULL; |
st.wYear = (WORD)ptm->tm_year; |
530 |
} /* reset_active_window */ |
st.wMonth = (WORD)ptm->tm_mon; |
531 |
|
st.wDay = (WORD)ptm->tm_mday; |
532 |
|
st.wYear += 1900; |
533 |
|
st.wMonth += 1; |
534 |
|
if (!GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, |
535 |
|
NULL, buf, buflen)) |
536 |
|
return NULL; |
537 |
|
return buf; |
538 |
|
} |
539 |
|
|
540 |
|
|
541 |
static DWORD CALLBACK |
struct reminder_hd_s { |
542 |
reminder_thread (void *ctx) |
int msecs; |
543 |
{ |
HWND dlg; |
544 |
reminder_ctx_s *c = (reminder_ctx_s *)ctx; |
HANDLE hd; |
545 |
|
}; |
546 |
|
|
|
Sleep( c->msecs ); |
|
|
SetForegroundWindow( activ_hwnd ); |
|
547 |
|
|
548 |
|
static DWORD CALLBACK |
549 |
|
foreground_reminder_thread (void *c) |
550 |
|
{ |
551 |
|
struct reminder_hd_s *ctx = (struct reminder_hd_s *)c; |
552 |
|
Sleep (ctx->msecs); |
553 |
|
SetForegroundWindow (ctx->dlg); |
554 |
|
CloseHandle (ctx->hd); |
555 |
|
delete ctx; |
556 |
|
ExitThread (0); |
557 |
return 0; |
return 0; |
558 |
} /* reminder_thread */ |
} |
|
|
|
559 |
|
|
560 |
HANDLE |
/* Try to force the window @dlg to the foreground. |
561 |
window_reminder( struct reminder_ctx_s *ctx ) |
On NT5 or later this will not work if the user |
562 |
|
is working in another window (console for example). */ |
563 |
|
void |
564 |
|
force_foreground_window (HWND dlg, int msecs) |
565 |
{ |
{ |
566 |
DWORD tid = 0; |
struct reminder_hd_s *hd; |
567 |
|
DWORD tid; |
568 |
return CreateThread( NULL, 0, reminder_thread, ctx, 0, &tid ); |
|
569 |
} /* window_reminder */ |
hd = new reminder_hd_s; |
570 |
|
hd->dlg = dlg; |
571 |
|
hd->msecs = msecs; |
572 |
|
hd->hd = CreateThread (NULL, 0, foreground_reminder_thread, |
573 |
|
hd, NULL, &tid); |
574 |
|
} |