/[winpt]/trunk/Src/wptW32API.cpp
ViewVC logotype

Diff of /trunk/Src/wptW32API.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 23 by twoaday, Fri Sep 30 10:10:16 2005 UTC revision 32 by twoaday, Mon Oct 24 08:03:48 2005 UTC
# Line 35  Line 35 
35    
36  extern "C" void _SHFree (void *p);  extern "C" void _SHFree (void *p);
37    
38  /* The the text of a menu item. */  
39  void  static void
40  set_menu_text (HMENU menu, int m_uid, const char *text)  set_menu_text_ext (HMENU menu, int by_pos, int m_uid, const char *text)
41  {  {
42      MENUITEMINFO mii;      MENUITEMINFO mii;
     char menu_text[80];  
       
     memset (&mii, 0, sizeof (mii));  
     mii.cbSize = sizeof (mii);  
     mii.fMask = MIIM_TYPE;  
     mii.dwTypeData = menu_text;  
     mii.cch = sizeof (menu_text);  
     GetMenuItemInfo (menu, m_uid, FALSE, &mii);  
43            
44      memset (&mii, 0, sizeof mii);      memset (&mii, 0, sizeof mii);
45      mii.cbSize = sizeof mii;      mii.cbSize = sizeof mii;
46      mii.fMask = MIIM_TYPE;      mii.fMask = MIIM_TYPE;
47      mii.fType = MFT_STRING;      mii.fType = MFT_STRING;
48      mii.dwTypeData = (char *) text;      mii.dwTypeData = (char *) text;
49      SetMenuItemInfo (menu, m_uid, FALSE, &mii);      SetMenuItemInfo (menu, m_uid, by_pos? TRUE : FALSE, &mii);
50  } /* set_menu_text */  }
51    
52    
53    /* Set the text of a menu item @m_uid to @text. */
54    void
55    set_menu_text (HMENU menu, int m_uid, const char *text)
56    {
57        set_menu_text_ext (menu, 0, m_uid, text);
58    }
59    
60    
61    /* Set the text of a menu item with the position @pos to @text. */
62    void
63    set_menu_text_bypos (HMENU menu, int pos, const char *text)
64    {
65        set_menu_text_ext (menu, 1, pos, text);
66    }
67    
68    
69    /* Set the state of a menu item @m_uid to @state. */
70  void  void
71  set_menu_state (HMENU menu, int m_uid, int state)  set_menu_state (HMENU menu, int m_uid, int state)
72  {        {      
# Line 68  set_menu_state (HMENU menu, int m_uid, i Line 77  set_menu_state (HMENU menu, int m_uid, i
77      mii.fMask = MIIM_STATE;      mii.fMask = MIIM_STATE;
78      mii.fState = state;      mii.fState = state;
79      SetMenuItemInfo (menu, m_uid, FALSE, &mii);      SetMenuItemInfo (menu, m_uid, FALSE, &mii);
80  } /* set_menu_state */  }
81    
82    
83    
84  /* Use the common dialog to request a file from the user.  /* Use the common dialog to request a file from the user.
# Line 87  get_filename_dlg (HWND hwnd, int id, con Line 97  get_filename_dlg (HWND hwnd, int id, con
97          memset (file, 0, sizeof (file));          memset (file, 0, sizeof (file));
98      if (!filter)      if (!filter)
99          filter = _("All Files (*.*)\0*.*\0\0");          filter = _("All Files (*.*)\0*.*\0\0");
100        /* XXX: problem with gettext because of the 'artificial'
101                double string termination!. */
102      memset (&open, 0, sizeof (open));      memset (&open, 0, sizeof (open));
103      open.lStructSize = sizeof (OPENFILENAME);      open.lStructSize = sizeof (OPENFILENAME);
104      open.hInstance = glob_hinst;      open.hInstance = glob_hinst;
# Line 108  get_filename_dlg (HWND hwnd, int id, con Line 120  get_filename_dlg (HWND hwnd, int id, con
120      return NULL;      return NULL;
121  }  }
122    
123    const char*
124    get_filesave_dlg (HWND hwnd, const char *title,
125                      const char *filter, const char *name)
126    {
127        return get_filename_dlg (hwnd, FILE_SAVE, title, filter, name);
128    }
129    
130    const char *
131    get_fileopen_dlg (HWND hwnd, const char *title, const char *filter,
132                      const char *name)
133    {
134        return get_filename_dlg (hwnd, FILE_OPEN, title, filter, name);
135    }
136    
137    
138  /* Use the common dialog to allow the user to select a folder.  /* Use the common dialog to allow the user to select a folder.
139     The return value is either the folder path or NULL if cancel was chosen. */     The return value is either the folder path or NULL if cancel was chosen. */
140  const char*  const char*
# Line 171  leave: Line 198  leave:
198  }  }
199    
200    
201  /* Set the the given text to the clipboard. */  /* Set @text as the new clipboard content. */
202  int  int
203  set_clip_text (HWND hwnd, const char *text, int nbytes)  set_clip_text (HWND hwnd, const char *text, int nbytes)
204  {      {    
# Line 260  make_filename (const char *path, const c Line 287  make_filename (const char *path, const c
287  /* return 0 if it exists, otherwise >0. */  /* return 0 if it exists, otherwise >0. */
288  int  int
289  file_exist_check (const char * fname)  file_exist_check (const char * fname)
290  {        {
291      HANDLE fh;        struct stat st;
292        if (stat (fname, &st) == -1)
     fh = CreateFile( fname, GENERIC_READ, FILE_SHARE_READ,  
                      NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );  
     if( fh == INVALID_HANDLE_VALUE )  
293          return WPTERR_FILE_EXIST;          return WPTERR_FILE_EXIST;
     CloseHandle( fh );  
294      return 0;      return 0;
295  }  }
296    

Legend:
Removed from v.23  
changed lines
  Added in v.32

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26