![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Пользователь
Регистрация: 22.01.2011
Сообщений: 78
|
![]()
Дано диалоговое окно с шестью кнопками: copy, paste, cut, delete, select all, undo. Как сделать так, чтобы static отображал позицию курсора по индексу?
Код HTML:
#include <Windows.h>
#include "resource.h"
HINSTANCE hInst;
BOOL CALLBACK DlgProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hInstPrev, LPSTR CmdLine, int CmdShow)
{
hInst=hInstance;
return DialogBox(hInst, (LPCWSTR)IDD_DIALOG1, NULL, DlgProc);
}
BOOL CALLBACK DlgProc (HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
int x,y;
switch (uMessage)
{
case WM_MOUSEMOVE:
char line[30],position[10];
strcpy(line,"x: ");
strcat(line,itoa(LOWORD(lParam),position,10));
strcat(line," y: ");
strcat(line,itoa(HIWORD(lParam),position,10));
SetWindowTextA(hWnd,line);
return TRUE;
case WM_COMMAND:
if(LOWORD(wParam)==IDC_BUTTON1)// проверка нажатой кнопки
{
SendDlgItemMessageW( hWnd,IDC_EDIT1, WM_COPY,0,0);
}
if(LOWORD(wParam)==IDC_BUTTON2)
{
SendDlgItemMessageW( hWnd,IDC_EDIT1, WM_PASTE,0,0);
}
if(LOWORD(wParam)==IDC_BUTTON3)
{
SendDlgItemMessageW( hWnd,IDC_EDIT1, WM_CUT,0,0);
}
if(LOWORD(wParam)==IDC_BUTTON4)
{
SendDlgItemMessageW( hWnd,IDC_EDIT1, WM_CLEAR,0,0);
}
if(LOWORD(wParam)==IDC_BUTTON5)
{
SendDlgItemMessageW( hWnd,IDC_EDIT1,EM_SETSEL,0,-1);
}
if(LOWORD(wParam)==IDC_BUTTON6)
{
SendDlgItemMessageW( hWnd,IDC_EDIT1,EM_UNDO,0,0);
}
if(LOWORD(wParam)==IDC_EDIT1)
{
if(SendMessage(hWnd,WM_GETTEXTLENGTH,0,0)
{
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON1),TRUE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON2),TRUE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON3),TRUE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON4),TRUE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON5),TRUE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON6),TRUE);
}
else
{
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON1),FALSE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON2),FALSE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON3),FALSE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON4),FALSE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON5),FALSE);
EnableWindow(GetDlgItem(hWnd,IDC_BUTTON6),FALSE);
}
return TRUE;
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
EndDialog(hWnd, 0);
return TRUE;
}
return FALSE;
}
|
![]() |
![]() |