RTFPAD


22 , Windows 95 RTFPAD. , RTF. .

Microsoft IntelliMouse, RTFPAD. 3.7 WinMain WndProc.

, Microsoft Windows 95, Microsoft NT 4.0.

3.7 (). rtfpad\rtfpad.

// =====================================================

// RTFPAD,

// Microsoft IntelliMouse

//

// (C) ., 1996, 1997

//

// E-mail: frolov@glas.apc.org

// WWW: http://www.glasnet.ru/~frolov

//

// http://www.dials.ccas.ru/frolov

// =====================================================

// ,

// winuser.h

// SPI_GETWHEELSCROLLLINES

// WM_MOUSEWHEEL

#define _WIN32_WINNT 0x0400

//

//#ifndef SPI_GETWHEELSCROLLLINES

//#define SPI_GETWHEELSCROLLLINES 104

//#endif

//#ifndef WM_MOUSEWHEEL

//#define WM_MOUSEWHEEL WM_MOUSELAST+1

//#endif

#define STRICT

#include <windows.h>

#include <windowsx.h>

#include <commctrl.h>

#include <richedit.h>

//

// UINT_MAX, zmouse.h

#include <limits.h>

#include "resource.h"

#include "afxres.h"

// IntelliMouse

#include "zmouse.h"


#include "rtfpad.h"

// MSH_MOUSEEHEEL

UINT uMSH_MOUSEEHEEL = 0;

// MSH_SUPPORT

UINT uMSH_SUPPORT = 0;

// MSH_SCROLL_LINES

UINT uMSH_SCROLL_LINES = 0;

//

// MSWheel

HWND hwndMSHWheel = NULL;

// Microsoft IntelliMouse

BOOL fWheel = FALSE;

//

UINT uiScrollLines = 3;

//

//

OSVERSIONINFO osv;

HINSTANCE hInst;

char szAppName[] = "RtfEditApp";

char szAppTitle[] = "Rich Text Editor RtfPad";

HWND hwndEdit;

HINSTANCE hRTFLib;

// -----------------------------------------------------

// WinMain

// -----------------------------------------------------

int APIENTRY

WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

LPSTR lpCmdLine, int nCmdShow)

{

WNDCLASSEX wc;

HWND hWnd;

MSG msg;



hInst = hInstance;

hWnd = FindWindow(szAppName, NULL);

if(hWnd)

{

if(IsIconic(hWnd))

ShowWindow(hWnd, SW_RESTORE);

SetForegroundWindow(hWnd);

return FALSE;

}

//

memset(&osv, 0, sizeof(OSVERSIONINFO));

osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

GetVersionEx(&osv);

// Windows 95 Windows NT 3.51

//

if( (osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)

((osv.dwPlatformId == VER_PLATFORM_WIN32_NT) &&

(osv.dwMajorVersion < 4)))

{

// MSH_WHEELSUPPORT

uMSH_SUPPORT =

RegisterWindowMessage(MSH_WHEELSUPPORT);



// Microsoft IntelliMouse

hwndMSHWheel =

FindWindow(MSH_WHEELMODULE_CLASS,

MSH_WHEELMODULE_TITLE);



if(uMSH_SUPPORT != 0 && hwndMSHWheel != 0)



{

fWheel =

(BOOL)SendMessage(hwndMSHWheel, uMSH_SUPPORT, 0, 0);

}

if(!fWheel)

{

MessageBox(NULL, "MS Wheel not supported",

"Error message", MB_OK);

}



// MSH_MOUSEWHEEL

uMSH_MOUSEEHEEL = RegisterWindowMessage(MSH_MOUSEWHEEL);

if(!uMSH_MOUSEEHEEL)

{

MessageBox(NULL, "Error: RegisterWindowMessage",

"Error message", MB_OK);

return FALSE;

}

// MSH_SCROLL_LINES

uMSH_SCROLL_LINES =

RegisterWindowMessage(MSH_SCROLL_LINES);



//

if(uMSH_SCROLL_LINES != 0 && hwndMSHWheel != 0)

{

uiScrollLines =

(BOOL)SendMessage(hwndMSHWheel,

uMSH_SCROLL_LINES, 0, 0);

}

}

// Windows NT 4.0

else

{

// Microsoft IntelliPoint

if(!GetSystemMetrics(SM_MOUSEWHEELPRESENT))

{

MessageBox(NULL,

"Microsoft IntelliMouse not found",

"Error message", MB_OK);

}

//

SystemParametersInfo(SPI_GETWHEELSCROLLLINES,

0, &uiScrollLines, 0);

}

hRTFLib = LoadLibrary("RICHED32.DLL");

if(!hRTFLib)

return FALSE;

memset(&wc, 0, sizeof(wc));

wc.cbSize = sizeof(WNDCLASSEX);

wc.hIconSm = LoadImage(hInst,

MAKEINTRESOURCE(IDI_APPICONSM), IMAGE_ICON, 16, 16, 0);

wc.style = 0;

wc.lpfnWndProc = (WNDPROC)WndProc;

wc.cbClsExtra = 0;

wc.cbWndExtra = 0;

wc.hInstance = hInst;

wc.hIcon = LoadImage(hInst,

MAKEINTRESOURCE(IDI_APPICON), IMAGE_ICON, 32, 32, 0);

wc.hCursor = LoadCursor(NULL, IDC_ARROW);

wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);

wc.lpszMenuName = MAKEINTRESOURCE(IDR_APPMENU);

wc.lpszClassName = szAppName;

if(!RegisterClassEx(&wc))



if(!RegisterClass((LPWNDCLASS)&wc.style))

return FALSE;



hWnd = CreateWindow(szAppName, szAppTitle,

WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0,

CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);

if(!hWnd) return(FALSE);

ShowWindow(hWnd, nCmdShow);

UpdateWindow(hWnd);

while(GetMessage(&msg, NULL, 0, 0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

return msg.wParam;

}

// -----------------------------------------------------

// WndProc

// -----------------------------------------------------

LRESULT WINAPI

WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)

{

//

short zDelta;

switch(msg)

{

HANDLE_MSG(hWnd, WM_CREATE, WndProc_OnCreate);

HANDLE_MSG(hWnd, WM_DESTROY, WndProc_OnDestroy);

HANDLE_MSG(hWnd, WM_COMMAND, WndProc_OnCommand);

HANDLE_MSG(hWnd, WM_SIZE, WndProc_OnSize);

HANDLE_MSG(hWnd, WM_SETFOCUS, WndProc_OnSetFocus);

default:

{

if(msg == WM_MOUSEWHEEL)

{

zDelta = (short)HIWORD(wParam);

if(zDelta < 0)

if(uiScrollLines != WHEEL_PAGESCROLL)

SendMessage(hwndEdit, EM_LINESCROLL, 0,

uiScrollLines);



else

SendMessage(hwndEdit, EM_SCROLL,

(WPARAM)(INT)SB_PAGEDOWN, 0);

else



if(uiScrollLines != WHEEL_PAGESCROLL)

SendMessage(hwndEdit, EM_LINESCROLL, 0,

-(LPARAM)uiScrollLines);



else

SendMessage(hwndEdit, EM_SCROLL,

(WPARAM)(INT)SB_PAGEUP, 0);

return 0L;

}

else if(msg == uMSH_MOUSEEHEEL)

{

zDelta = (short)wParam;

if(zDelta < 0)

if(uiScrollLines != WHEEL_PAGESCROLL)

SendMessage(hwndEdit, EM_LINESCROLL, 0,

uiScrollLines);



else

SendMessage(hwndEdit, EM_SCROLL,

(WPARAM)(INT)SB_PAGEDOWN, 0);

else



if(uiScrollLines != WHEEL_PAGESCROLL)

SendMessage(hwndEdit, EM_LINESCROLL, 0,

-(LPARAM)uiScrollLines);



else

SendMessage(hwndEdit, EM_SCROLL,

(WPARAM)(INT)SB_PAGEUP, 0);



return 0L;

}

return(DefWindowProc(hWnd, msg, wParam, lParam));

}

}

}

. . .

, . , , . .










Forekc.ru
, , , , , , , , , ,