Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Bu bölümdeki örnekte animasyonlu statik denetimin nasıl oluşturulacağı gösterilmektedir.
Bilmeniz gerekenler
Teknolojileri
Önkoşullar
- C/C++
- Windows Kullanıcı Arayüzü Programlama
Talimatlar
Statik Denetim Oluşturma
Aşağıdaki kod örneğinde, iletişim kutusundaki statik simge denetimine animasyon eklemek için zamanlayıcı ve STM_SETICON iletisi kullanılmaktadır.
#define MAXICONS 3
#define HALF_SECOND 500
INT_PTR CALLBACK StaticDlgProc(HWND hDlg, UINT message, WPARAM wParam,
LPARAM lParam)
{
static HICON aIcons[MAXICONS];
static UINT i = 0;
static UINT idTimer = 1;
switch (message)
{
case WM_INITDIALOG:
// Load the icon resources. g_hInst is the global instance handle.
aIcons[i] = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON1));
aIcons[++i] = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
aIcons[++i] = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON3));
// Reset the array index.
i = 0;
// Set a timer.
SetTimer(hDlg, idTimer, HALF_SECOND, (TIMERPROC) NULL);
return TRUE;
case WM_TIMER:
// Use STM_SETICON to associate a new icon with the static icon
// control whenever a WM_TIMER message is received.
SendDlgItemMessage(hDlg, IDC_STATIC_ICON, STM_SETICON,
(WPARAM) aIcons[i], 0);
// Reset the array index, if necessary.
if (++i == MAXICONS)
i = 0;
return 0;
case WM_COMMAND:
if (wParam == IDOK
|| wParam == IDCANCEL)
{
EndDialog(hDlg, TRUE);
}
return TRUE;
case WM_DESTROY:
KillTimer(hDlg, idTimer);
// Note that it is not necessary to call DestroyIcon 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);
}
Açıklamalar
Statik simge denetiminin (IDI_STATIC_ICON) tanımlayıcısı genel üst bilgi dosyasında tanımlanır ve simgeler uygulama kaynaklarından yüklenir.
İlgili konular