wxWidgets一些代码片段

1、获得本程序的进程ID
        long gpid; 
        gpid=::wxGetProcessId(); 
        wxString tempWxString; 
        tempWxString.sprintf(wxT("%d"), gpid); 
        wxMessageBox(tempWxString, _("Welcome to..."));
 
2、定时器
        ::wxStartTimer(); 
        long gt; 
        gt=::wxGetElapsedTime(true); 
        wxString tempWxString; 
        tempWxString.sprintf(wxT("is %d second"), gt/1000); 
        wxMessageBox(tempWxString, _("Welcome to..."));
 
3、一句话COPY文件
//bool wxCopyFile(const wxString& file1, const wxString& file2, bool overwrite = true) 
 
::wxCopyFile("c:\\README.TXT","d:\\1.txt",true);
 
4、获得系统文件夹
        wxString osDirectory; 
        osDirectory=::wxGetOSDirectory(); 
        wxMessageBox(osDirectory, _("Welcome to..."));
 
5、获得系统版本信息
        wxString OsVersion; 
        OsVersion=::wxGetOsDescription(); 
        wxMessageBox(OsVersion, _("axi Test"));
 
6、窗体坐标
        wxPoint wp; 
        wp=frame->GetClientAreaOrigin(); 
        int x1,y1; 
        x1=wp.x; 
        y1=wp.y; 
        wxString tempWxString; 
        tempWxString.sprintf(wxT("x: %d y: %d"), x1,y1); 
        wxMessageBox(tempWxString, _("frame xy"));
 
其他的一些文件操作
::wxRemoveFile 
bool wxRemoveFile(const wxString& file) 
 
Removes file, returning true if successful. 
 
 
 

 
::wxRenameFile 
bool wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite = true) 
 
Renames file1 to file2, returning true if successful. 
 
If overwrite parameter is true (default), the destination file is overwritten if it exists, but if overwrite is false, the functions fails in this case. 
 
::wxRmdir 
bool wxRmdir(const wxString& dir, int flags=0) 
 
Removes the directory dir, returning true if successful. Does not work under VMS. 
 
The flags parameter is reserved for future use. 
 
Please notice that there is also a wxRmDir() function which simply wraps the standard POSIX rmdir() function and so return an integer error code instead of a boolean value (but otherwise is currently identical to wxRmdir), don't confuse these two functions. 
 

你可能感兴趣的:(wxwidgets)