volcanol的工控博客
Email : lilinly225@126.com 索要资料加QQ 点击进入 或 点击左侧的资料分享专用帖

volcanol ---- View OF Linux Can Appreciate Nature OF Linux

天行健,君子以自强不息

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
/*
  本程序测试自定义的WinMainCRTStartup函数
*/

#define STRICT
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <tchar.h>
#include <assert.h>

//PIMAGE_DOS_HEADER 

void CenterText(HDC hDC,int x,int y,LPCTSTR szFace,LPCTSTR szMessage,int point)
{
    HFONT hFont=CreateFont(- point * GetDeviceCaps(hDC,LOGPIXELSY)/72,
                            0,
                            0,
                            0,
                            FW_BOLD,
                            TRUE,
                            FALSE,
                            FALSE,
                            ANSI_CHARSET,
                            OUT_TT_PRECIS,
                            CLIP_DEFAULT_PRECIS,
                            PROOF_QUALITY,
                            VARIABLE_PITCH,
                            szFace
                            );
    assert(hFont);

    HGDIOBJ hOld=SelectObject(hDC,hFont);
    SetTextAlign(hDC,TA_CENTER | TA_BASELINE);
    SetBkMode(hDC,TRANSPARENT);
    SetTextColor(hDC,RGB(0,0,0xFF));
    TextOut(hDC,x,y,szMessage,_tcslen(szMessage));
    SelectObject(hDC,hOld);
    DeleteObject(hOld);
}

const TCHAR szMessage[]=_T("Hello world");
const TCHAR szFace[]=_T("Times New Roman");

#pragma comment(linker,"-merge:rdata=.text")
//#pragma comment(linker,"-align:512")

extern "C" void WinMainCRTStartup()
{
    HDC hDC=GetDC(NULL);
    assert(hDC);

    CenterText(hDC,GetSystemMetrics(SM_CXSCREEN)/2,GetSystemMetrics(SM_CYSCREEN)/2,szFace,szMessage,72);

    ReleaseDC(NULL,hDC);
    ExitProcess(0);
}

 

posted on 2016-04-03 08:49  volcanol  阅读(438)  评论(0编辑  收藏  举报
volcanol ----View OF Linux Can Appreciate Nature OF Linux。