用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心编程技巧Visual C++

Win32问答之位图篇

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 20:32:47

小辉论坛精华贴

Q://问了无数大虾,可无一人知道??!!VCSDK(不用MFC)编程如何将HINST_COMMCTRL系统提供的图形按钮改成自己的位图?
//
问题:如何将HINST_COMMCTRL系统提供的图形按钮改成自己的位图?问题在下面!我有注释!

#include <windows.h>
#include <commdlg.h>
#include <stdio.h>
#include <stdlib.h>
#include <commctrl.h>
#include "
窗口类控件示例.h"

OPENFILENAME ofn;
HWND hStatusBar,hToolBar;

HINSTANCE hInst;
int RightEnd[2];

LPNMHDR lpnmhdr;
LPTOOLTIPTEXT lpttext;

//定义工具栏按钮
TBBUTTON tbButton[]=
{
STD_FILENEW,IDM_NEW,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,
STD_FILEOPEN,IDM_OPEN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,
STD_FILESAVE,IDM_SAVE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,
0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0,0,0,
STD_CUT,IDM_CUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,
STD_COPY,IDM_COPY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,
STD_PASTE,IDM_PASTE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,0,0,
};


LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);

int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInst,
LPSTR lpszCmdLine,
int nCmdShow)
{
HWND hwnd ;
MSG Msg ;
HACCEL hAccel;
WNDCLASS wndclass ;
char lpszMenuName[]="Menu";
char lpszClassName[] = "
窗口类控件";
char lpszTitle[]= "
窗口类控件示例";

wndclass.style = 0;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon( NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW) ;
wndclass.hbrBackground = GetStockObject( WHITE_BRUSH) ;
wndclass.lpszMenuName = lpszMenuName ;
wndclass.lpszClassName = lpszClassName ;

if( !RegisterClass( &wndclass))
{
MessageBeep(0) ;
return FALSE ;
}

hwnd = CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL) ;

ShowWindow( hwnd, nCmdShow) ;
UpdateWindow(hwnd);

InitCommonControls(); //初始化通用控件

hInst=hInstance;
hAccel=LoadAccelerators(hInst,lpszMenuName);
while( GetMessage(&Msg, NULL, 0, 0))
{
if (!TranslateAccelerator(hwnd,hAccel,&Msg))
{
TranslateMessage( &Msg) ;
DispatchMessage( &Msg) ;
}
}

return Msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)

{
static char szFilter[] = "Text Files (*.TXT)

Tags:

作者:佚名
  • 好的评价 如果您觉得此文章好,就请您
      0%(0)
  • 差的评价 如果您觉得此文章差,就请您
      0%(0)

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:6,015.62500 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号