http://M.TangGaowei.com

分类: 手机开发

2008-05-08 16:34:22  | 7,911 次浏览

(虽然能捕捉到,但是好像最后还是执行了返回桌面操作)

1. 注册热键

BOOL CMyProjectDlg::OnInitDialog()
{
    …

    // 处理 VK_HOME
    BYTE appkey = SHGetAppKeyAssoc(_T(“MiniBlogClient.exe”));
    ::RegisterHotKey ( m_hWnd, appkey, MOD_WIN, VK_THOME);

    …
}

2. 重写 PreTranslateMessage 函数

BOOL CMyProjectDlg::PreTranslateMessage(MSG* pMsg)
{
    // TODO: 在此添加专用代码和/或调用基类
    if( pMsg->message == WM_HOTKEY )
    {
        SetForegroundWindow();

        return TRUE;
    }

    return CDialog::PreTranslateMessage(pMsg);
}

[ 标签: HOME键 ]
[ 固定链接:http://m.tanggaowei.com/2008/05/08/73.html ]
2008-05-08 16:33:19  | 8,027 次浏览

在手机里,按下 HOME 键后,在“任务管理器(CeleTask.exe)”里就找不到应用程序了。碰到这样的事情,真是很郁闷!解决方法如下:

在“资源视图”的窗口编辑器里,将窗口的 style 属性修改为 Overlapped,再重新编译

[ 标签: HOME键, 任务管理器 ]
[ 固定链接:http://m.tanggaowei.com/2008/05/08/72.html ]
2008-05-08 16:31:45  | 8,373 次浏览

1. 控件获得焦点时,屏蔽输入法

void CBlogEdit::OnSetFocus(CWnd* pOldWnd)
{
    CEdit::OnSetFocus(pOldWnd);

    // 关闭输入法
    HIMC hIMC = ImmGetContext( this->GetSafeHwnd() );
    ImmSetOpenStatus ( hIMC, FALSE );
}

2. 映射 WM_CHAR 消息到 OnChar ()

void CBlogEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    // nChar 的值在不同手机上可能有所不同
    switch ( nChar )
    {
        // Up
        case 50:
        {
            this->LineScroll ( -1 );

            break;
        }

        // Down
        case 56:
        {
            this->LineScroll ( 1 );

            break;
        }

        // PageUp
        case 52:
        {
            this->LineScroll ( -11 );

            break;
        }

        // PageDown
        case 54:
        {
            this->LineScroll ( 11 );

            break;
        }
    }

    // CEdit::OnChar(nChar, nRepCnt, nFlags);
}

[ 标签: Edit控件, 屏蔽输入法, 翻页 ]
[ 固定链接:http://m.tanggaowei.com/2008/05/08/71.html ]
2008-05-08 16:30:47  | 7,667 次浏览

#include <windows.h>
#include <afxwin.h>
#include <atltime.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

int _tmain(int argc, _TCHAR* argv[])
{
    char           buff[80];
    __time64_t result;

    // 构造 2008年4月28日 22:18:39 的时间
    CTime        t(2008,4,28,22,18,39);

    CString s = t.Format( _T(“%A, %B %d, %Y”) );

    struct tm when;
    t.GetLocalTm(&when);

    // 在自定义的时间上,再加 8 小时
    // 即变为 2008年4月29日 6:18:39
    when.tm_hour = when.tm_hour + 8; 

    // 重构时间,并输出显示
    if( (result = mktime( &when )) != (time_t)-1 )
    {
        asctime_s( buff, sizeof(buff), &when );
        printf( “the time will be %s\n”, buff );
    }
    else
    {
        printf( “mktime failed” );
    }
}

[ 标签: 时间处理 ]
[ 固定链接:http://m.tanggaowei.com/2008/05/08/70.html ]
2008-05-08 16:29:53  | 8,940 次浏览

#include <fstream>
using namespace std;

// AuthInfo 是自定义的 struct
struct AuthInfo auth_info;
string susername, spassword;

/* 写文件 */ 
// 清零
ZeroMemory ( &auth_info, sizeof ( auth_info ) );

susername = “tanggaowei@gmail.com”;
spassword = “000000″;

// 内存拷贝
memcpy(auth_info.username, susername.c_str(), susername.length());
memcpy(auth_info.password, spassword.c_str(), spassword.length());

// 定义打开输出流
ofstream fout(“mbc.dat”, ios::binary);

// 写入
fout.write((char *)(&auth_info), sizeof(auth_info));

// 关闭输出流
fout.close();

/* 读文件 */
ZeroMemory ( &auth_info, sizeof ( auth_info ) );

ifstream fin ( “mbc.dat”, ios::binary );

fin.read((char *)(&auth_info), sizeof(auth_info));

susername = auth_info.username;
spassword = auth_info.password;

ZeroMemory ( auth_info.username, 100 );   // AuthInfo.username[100]
ZeroMemory ( auth_info.password, 50 );    
// AuthInfo.password[50]

memcpy(auth_info.username, susername.c_str(), susername.length());
memcpy(auth_info.password, spassword.c_str(), spassword.length());  

fin.close();

[ 标签: C++, 写文件, 读文件 ]
[ 固定链接:http://m.tanggaowei.com/2008/05/08/69.html ]

简介

随时随地(路上、车上、排队等)都可以进行交流、娱乐、学习、工作——移动新世界!

订阅

 

手机访问

http://m.tanggaowei.com/wap/
查找文章: