Morya

自己写的小工具,本来是用perl写的命令行版本

支持 shutdown -s -t 3h20m 类似的东西

后来还是觉得打命令麻烦……
干脆,造了一个GUI的。

(*貌似zoundry的上传在cppblog不好用,或者是我不会设置。。 我一直以为有图片了……)

shut.7z

posted @ 2009-05-21 14:51 Morya 阅读(275) | 评论 (0)编辑 收藏
wxStandardPaths().GetDataDir()

这个函数可以用来非常方便的取得exe的位置。(Manual)

可是用vc编译的debug版却没有包含最后的debug目录。
很是疑惑啊!
以为vc添加了什么神奇的东西。
看了
wxStandardPaths::GetDataDir() 的源代码,
1 wxString wxStandardPaths::GetDataDir() const
2 {
3    // under Windows each program is usually installed in its own directory and
4    // so its datafiles are in the same directory as its main executable
5    return GetAppDir();
6 }

 1 wxString wxStandardPaths::GetAppDir()
 2 {
 3    wxFileName fn(wxGetFullModuleName());
 4 
 5    // allow running the apps directly from build directory in debug builds
 6 #ifdef __WXDEBUG__
 7    wxString lastdir;
 8    if ( fn.GetDirCount() )
 9    {
10       lastdir = fn.GetDirs().Last();
11       lastdir.MakeLower();
12       if ( lastdir.Matches(_T("debug*")) || lastdir.Matches(_T("vc_msw*")) )
13       fn.RemoveLastDir();
14    }
15 }
16 

posted @ 2009-04-12 20:27 Morya 阅读(578) | 评论 (0)编辑 收藏
     摘要: ::wxGetTranslation()

const wxChar * wxGetTranslation(const wxChar* str, const wxChar* domain = NULL)

const wxChar * wxGetTranslation(const wxChar* str, const wxChar* strPlural, size_t n, const wxChar* domain = NULL)

This function returns the translation of string str in the current locale. If the string is not found in any of the loaded message catalogs (see internationalization overview), the original string is returned. In debug build, an error message is logged -- t  阅读全文
posted @ 2008-12-24 14:24 Morya 阅读(981) | 评论 (1)编辑 收藏
     摘要: 当Adobe、Microsoft、Sun等一系列巨头开始表现出对”开源”的青睐时,”开源”的时代即将到来!

最初来自:http://www.sinoprise.com/read.php?tid-662-page-e-fpage-1.html(遗憾的是这个链接已经打不开了),我基本未改动,只是进行了一些排版和整理。
参考文献:http://www.fsf.org/licensing/licenses/

现今存在的开源协议很多,而经过Open Source Initiative组织通过批准的开源协议目前有58种(http://www.opensource.org/licenses/alphabetical)。我们在常见的开源协议如BSD, GPL, LGPL,MIT等都是OSI批准的协议。如果要开源自己的代码,最好也是选择这些被批准的开源协议。

这里我们来看四种最常用的开源协议及它们的适用范围,供那些准备开源或者使用开源产品的开发人员/厂家参考。

  阅读全文
posted @ 2008-12-10 20:42 Morya 阅读(262) | 评论 (2)编辑 收藏

突然觉得,是时候该转变一下视角了。 图片《灰色的城市》以后就是我的桌面。

城市.png

posted @ 2008-11-21 21:14 Morya 阅读(150) | 评论 (0)编辑 收藏
A wxPaintDC must be constructed if an application wishes to paint on the client area of a window from within an EVT_PAINT() event handler. This should normally be constructed as a temporary stack object; don't store a wxPaintDC object. If you have an EVT_PAINT() handler, you must create a wxPaintDC object within it even if you don't actually use it.

如果使用EVT_PAINT()分配paint事件处理函数,一定要在处理函数里创建一个wxPaintDC临时变量。否则程序会Halt。
posted @ 2008-11-05 17:06 Morya 阅读(251) | 评论 (0)编辑 收藏
看到wxWidgets可以静态事件编程,也可以动态事件编程 但是我编写动态事件的时候,还是需要编写一个enum 用来分配ID,毕竟没有ID就没法分配事件 偶然看到wxWindow的定义,才发现有一个GetID()可以用。 这样就方便多了。

wxButton * btn = new wxButton( this, wxID_ANY, wxT("Btn") );
Connect( btn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainWin::OnBtnClicked) );
posted @ 2008-11-04 22:03 Morya 阅读(174) | 评论 (0)编辑 收藏
class MainWin: public wxFrame;
无法通过
MainWin::MainWin(){
SetWindowStyleFlag(GetWindowStyleFlag() & ~wxCLOSE_BOX);
}
奏效,必须在构造函数中传入
MainWin::MainWin(const wxString & title):
wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE 
& ~( wxMAXIMIZE_BOX | wxCLOSE_BOX)) {;}


posted @ 2008-11-04 22:02 Morya 阅读(282) | 评论 (0)编辑 收藏
编译其实很简单,

下面这行,就可以实现。

nmake /f makefile.vc share=1
或者编辑config.* 文件。

编写程序,调用的引用库地址从 c:\wxwidgets-2.8.7\lib\vc_lib 换成 c:\wxwidgets-2.8.7\lib\vc_dll
只有一个要注意的事情 编译选项里
加上一个 WXUSINGDLL 预处理。
posted @ 2008-11-04 21:56 Morya 阅读(535) | 评论 (0)编辑 收藏

文件在OnInit()函数中可以自定义处理命令行解析。

文件 $(wxWidgetsDIR)\src\common\appbase.cpp

class WXDLLIMPEXP_BASE wxAppConsole : public wxEvtHandler
{
public:
/*
.
.
.
*/
    
// Called before OnRun(), this is a good place to do initialization -- if
    
// anything fails, return false from here to prevent the program from
    
// continuing. The command line is normally parsed here, call the base
    
// class OnInit() to do it.
    virtual bool OnInit();
};

否则,则可以在

bool TheApp::OnInit(){
   
if(!wxApp::OnInit()) return false;
// ..
// ..
}

可以在自己的OnInit()函数中自己处理命令行。

class TheApp : public wxApp{
public:
   TheApp();
   
virtual bool OnInit();
   
virtual int OnRun();
   
virtual void OnCmdLineParsed();
};

TheApp::OnInit(){
  
cmdParser.SetCmdLine( argc, argv);
bool cont;
cont 
= false;
OnInitCmdLine( cmdParser );

switch ( int parseResult = cmdParser.Parse( false /* don't show usage */) ){
   
case -1:// show usage message
    cont = false;
    
break;
   
case 0// normal parsed
    cont = OnCmdLineParsed( cmdParser);
    
break;
   
default// parsed error
    cont = false;// OnCmdLineError( cmdParser);
    break;
}
if!cont){
   
return false;
}

posted @ 2008-11-04 21:53 Morya 阅读(413) | 评论 (0)编辑 收藏
仅列出标题
共3页: 1 2 3 

导航

<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

统计

常用链接

留言簿(1)

随笔档案(21)

文章档案(1)

最新评论

评论排行榜