notepad源码2

一共有21个Cpp

先从winmain开始吧 。


参考另外一篇文章,在此我就不多写了。http://blog.csdn.net/spvm1313113/article/details/5978077


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdShow)
{
    HWND hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL);//这个API的目的是为了找到满足类名为第一个参数,而标题名为第二个参数的handle(句柄)
    if (hNotepad_plus)//为了保证Notepad++只存在一个实例
    {
        if (::IsIconic(hNotepad_plus))//确定给定窗口是否是最小化(图标化)的窗口
            ::OpenIcon(hNotepad_plus);//恢复一个最小化的程序,并将其激活


        ::SetForegroundWindow(hNotepad_plus);//创建指定窗口的线程设置到前台,并且激活该窗口
        if (lpszCmdLine[0])
        {
            COPYDATASTRUCT copyData;
            copyData.dwData = 0;//(ULONG_PTR);
            copyData.cbData = DWORD(strlen(lpszCmdLine) + 1);
            copyData.lpData = lpszCmdLine;
            ::SendMessage(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)&copyData);
        }
        return 0;
    }


Notepad_plus notepad_plus_plus;
MSG msg;
msg.wParam = 0;


try {
        char *pPathNames = NULL;
        if (lpszCmdLine[0])
        {
            pPathNames = lpszCmdLine;
        }
notepad_plus_plus.init(hInstance, NULL, pPathNames);//notepad_plus_plus初始化
HACCEL hAccTable = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_M30_ACCELERATORS));//调入指定的加速键表
MSG msg;
msg.wParam = 0;
while (::GetMessage(&msg, NULL, 0, 0))//检测是不是对话框的消息
{
// if the message doesn't belong to the notepad_plus_plus's dialog
if (!notepad_plus_plus.isDlgMsg(&msg))
{
if (::TranslateAccelerator(notepad_plus_plus.getHSelf(), hAccTable, &msg) == 0)
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
}
} catch(int i) {
if (i == 106901)
::MessageBox(NULL, "Scintilla.init is failled!", "106901", MB_OK);
else {
char str[50] = "God Damn Exception : ";
char code[10];
itoa(i, code, 10);
::MessageBox(NULL, strcat(str, code), "int exception", MB_OK);
}
}

catch(std::exception ex) {
::MessageBox(NULL, ex.what(), "Exception", MB_OK);
}
catch(...) {
systemMessage("System Err");
}


return (UINT)msg.wParam;
}


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值