如何变更图片!!!!!!小题高分

zxl_lim 2004-01-05 03:18:43
请问SDK编程下改变静太文本控件背景图片是什么方法啊.谢谢.
...全文
45 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
曾经的猎狐 2004-01-05
  • 打赏
  • 举报
回复
Using Static Controls

--------------------------------------------------------------------------------

The following example uses a timer and the STM_SETIMAGE message to animate an icon in a dialog box. The icon handles and the icon identifier (IDI_ICON) are defined in a global header file.

Hide Example

LRESULT CALLBACK StaticProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UINT idTimer = 1;
static UINT i;

static HICON aIcons[11];

switch (message)
{
case WM_INITDIALOG:
i = 0;

// Load icons("hinst" is defined globally).

hiconOne = LoadIcon(hinst, "OneIco");
aIcons[i] = hiconOne;
hiconTwo = LoadIcon(hinst, "TwoIco");
aIcons[++i] = hiconTwo;

// Continue with the remaining icons.
// ...

i = 0;

// Use STM_SETIMAGE to associate an icon with the
// IDI_ICON identifier.

SendDlgItemMessage(hDlg, // dialog box window handle
IDI_ICON, // icon identifier
STM_SETIMAGE, // message to send
(WPARAM) IMAGE_ICON, // image type
(LPARAM) aIcons[i++]); // icon handle

// Set a timer for 50-millisecond intervals.

SetTimer(hDlg, idTimer, 50, (TIMERPROC) NULL);
return TRUE;

case WM_TIMER:

// Use STM_SETIMAGE to associate a new icon with
// the IDI_ICON identifier whenever a WM_TIMER
// message is received.
SendDlgItemMessage(hDlg, // dialog box window handle
IDI_ICON, // icon identifier
STM_SETIMAGE, // message to send
(WPARAM) IMAGE_ICON, // image type
(LPARAM) aIcons[i++]); // new icon handle
if (i == 10)
i = 0;

break;

case WM_COMMAND:
if (wParam == IDOK
|| wParam == IDCANCEL)
{
EndDialog(hDlg, TRUE);
return TRUE;
}
return 0;

case WM_DESTROY: // clean up
KillTimer(hDlg, idTimer);
// Note that DestroyIcon is not correct here.
// LoadIcon obtains a shared icon, which is valid as long
// as the module from which it was loaded is in memory.

return 0;
}
return FALSE;
UNREFERENCED_PARAMETER(lParam);
}
曾经的猎狐 2004-01-05
  • 打赏
  • 举报
回复
STM_SETIMAGE
An application sends an STM_SETIMAGE message to associate a new image (icon or bitmap) with a static control.

STM_SETIMAGE

wParam = (WPARAM) fImageType; // image-type flag

lParam = (LPARAM) (HANDLE) hImage; // handle of the image


Parameters
fImageType
Value of wParam. Specifies the type of image to associate with the static control. This parameter can be one of the following values:
IMAGE_BITMAP
IMAGE_CURSOR
IMAGE_ENHMETAFILE
IMAGE_ICON


hImage
Value of lParam. Identifies the image to associate with the static control.
Return Values
The return value is the handle of the image previously associated with the static control, if any; otherwise, it is NULL
windyloft 2004-01-05
  • 打赏
  • 举报
回复
STM_SETIMAGE
七伤拳 2004-01-05
  • 打赏
  • 举报
回复
使用 STM_SETIMAGE 消息,参数请查阅MSDN

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧