Click here to Skip to main content
15,911,315 members
Home / Discussions / Article Writing
   

Article Writing

 
GeneralRe: news: protocol Pin
SAWilde7-Dec-00 22:46
SAWilde7-Dec-00 22:46 
GeneralRe: news: protocol Pin
Sasa Kajic8-Dec-00 2:59
Sasa Kajic8-Dec-00 2:59 
Generalnews: protocol Pin
Sasa Kajic7-Dec-00 0:47
Sasa Kajic7-Dec-00 0:47 
GeneralSending msg to Pager thru ASP Pin
6-Dec-00 4:26
suss6-Dec-00 4:26 
GeneralRe: Sending msg to Pager thru ASP Pin
SAWilde7-Dec-00 22:53
SAWilde7-Dec-00 22:53 
GeneralClipping Region of Child Window Controls Pin
Brian Rosenthal29-Nov-00 9:48
Brian Rosenthal29-Nov-00 9:48 
GeneralRe: Clipping Region of Child Window Controls Pin
Brian Rosenthal2-Dec-00 18:09
Brian Rosenthal2-Dec-00 18:09 
GeneralRe: Clipping Region of Child Window Controls Pin
Brian Rosenthal2-Dec-00 18:09
Brian Rosenthal2-Dec-00 18:09 
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif


#include <windows.h>
#include <math.h>
#include <iostream>
#include "richedit.h"

/*
* Define a block of globally accessible information
*/
typedef struct tagAPPBLOCK {
/* Windows types */
HINSTANCE hInstance; /* application instance */
HWND hMainWnd; /* handle to main window */
HWND hwndRichEditChatWindow; /* Host rich edit chat window */
HRGN hwndRichEditChatRegion; /* The region of the rich edit control */
HWND hwndGoButton;
} APPBLOCK, *LPAPPBLOCK;


// Define the WndProc function
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

APPBLOCK appblock;

/*
* Two child windows: A Rich edit control and a button
*/
#define ID_RICHEDITCHATWINDOW 1
#define ID_GOBUTTON 2


int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT("RichEdit Region Clipping Test"); // name
HWND hwnd; // this window
MSG msg; // for the message loop
WNDCLASS wndclass; // I will define a class for this window
char tmpStr[128]; // for debugging information

appblock.hInstance = hInstance; // Store the instance value in a global variable.

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 = (HBRUSH) GetStockObject(TRANSPARENT);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;

// LoadLibrary("Riched20.dll");
// Necessary to use the rich edit control
if (!LoadLibrary("Riched20.dll")) {
(void)MessageBox(NULL, "Error! Load Riched20.dll.", "Fatal Error.", MB_OK | MB_ICONASTERISK);
sprintf(tmpStr, "Error Information: %d", GetLastError());
return false;
}

// Register the class
if (!RegisterClass(&wndclass))
{
MessageBox(NULL, TEXT("Error registering the class"), szAppName, MB_ICONERROR);
return 0;
}

// Create a main window to hold the button and the rich edit control
hwnd = CreateWindow(
szAppName,
TEXT("Richedit Clipping Test"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);

while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return msg.wParam;
}


/*
* Contains a richedit and a button
*/
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HINSTANCE hInstance;
LPAPPBLOCK lpab;
char tmpStr[256];

// global block of information.
lpab = &appblock;

switch (message)
{
case WM_CREATE:
hInstance = lpab->hInstance;

// Create the richedit control
// Give it a black background
// Show it.
if (!(
lpab->hwndRichEditChatWindow = CreateWindowEx(
0,
RICHEDIT_CLASS, TEXT(""),
WS_CHILD | ES_MULTILINE | WS_VISIBLE, // !WS_BORDER & (WS_CHILD | WS_VISIBLE | BS_FLAT| BS_BITMAP),
5, // left
5, // top
500, // btnWidth, pressing the button will change the region to make part of this invisible
100, // btnHeight
hwnd,
(HMENU) ID_RICHEDITCHATWINDOW,
lpab->hInstance,
NULL)
)){
(void)sprintf(tmpStr, "Error. Could not create RichEditChatWindow. Error Information: %d", GetLastError());
(void)OutputDebugString(tmpStr);
(void)MessageBox(NULL, tmpStr, "Fatal Error.", MB_OK | MB_ICONASTERISK);
exit(1);
}

if (!(
lpab->hwndGoButton = CreateWindowEx(
0,
"button", TEXT("Go!"),
WS_CHILD | WS_VISIBLE, // !WS_BORDER & (WS_CHILD | WS_VISIBLE | BS_FLAT| BS_BITMAP),
20, // left
300, // top
50, // btnWidth
20, // btnHeight
hwnd,
(HMENU) ID_GOBUTTON,
lpab->hInstance,
NULL)
)){
(void)sprintf(tmpStr, "Error. Could not create Go Button. Error Information: %d", GetLastError());
(void)OutputDebugString(tmpStr);
(void)MessageBox(NULL, tmpStr, "Fatal Error.", MB_OK | MB_ICONASTERISK);
exit(1);
}


ShowWindow(lpab->hwndRichEditChatWindow, true);
ShowWindow(lpab->hwndGoButton, true);

SendMessage(lpab->hwndRichEditChatWindow, EM_SETTEXTMODE, TM_RICHTEXT, 0);
/*
* Set the background to yellow (okay, so this is an ugly color...).
*/
SendMessage(lpab->hwndRichEditChatWindow, EM_SETBKGNDCOLOR, 0, RGB(255, 255, 0));
InvalidateRgn(lpab->hwndRichEditChatWindow, NULL, true);
InvalidateRgn(lpab->hwndGoButton, NULL, true);
InvalidateRgn(hwnd, NULL, true);

return 0;

case WM_SIZE:
return 0;

case WM_COMMAND:
switch(LOWORD(wParam)) {
case ID_GOBUTTON:
if (HIWORD(wParam) == BN_CLICKED) {
// Define a small rectangle. Note, this is a global variable,
// and is not de-allocated until WM_DESTROY
lpab->hwndRichEditChatRegion = CreateRectRgn(0, 0,50, 50);

// Set the region of the richedit chat window to be the small rectangle.
SetWindowRgn(lpab->hwndRichEditChatWindow, lpab->hwndRichEditChatRegion, true);

// *********************
// WEIRD OUTCOME C:
// Invalidating the main window seems to
// nullify the SetWindowRgn call above

// InvalidateRect(hwnd, NULL, true);

// END WEIRD OUTCOME C

// **********************
// WEIRD OUTCOME D:
// Invalidating the RichEdit seems to
// nullify the SetWindowRgn call above

//InvalidateRect(lpab->hwndRichEditChatWindow, NULL, true);

// END WEIRD OUTCOME D

return 0;
}

break;
}
break;
case WM_PAINT:

// WEIRD OUTCOME B:
// If these lines are uncommented, there is erratic behavior. The
// go button disappears permanently, and the rich edit is not resized properly

//(void)SendMessage(lpab->hwndRichEditChatWindow, WM_PAINT, 0, 0);
//(void)SendMessage(lpab->hwndGoButton, WM_PAINT, 0, 0);
// return 0;

// END WEIRD OUTCOME B

// WEIRD OUTCOME A. If this line is uncommented, the child window is resized,
// but only temporarily. Alt-tabbing between applications seems to lose the region.
break;

// END WEIRD OUTCOME A

case WM_DESTROY:
DeleteObject(lpab->hwndRichEditChatRegion);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);

}
GeneralI think I understand wierd case 'A' Pin
Jim Howard5-Dec-00 6:48
Jim Howard5-Dec-00 6:48 
GeneralRe: I think I understand wierd case 'A' Pin
SAWilde7-Dec-00 22:41
SAWilde7-Dec-00 22:41 
GeneralDisplay selection in Button Controls Pin
Amit Dey27-Nov-00 10:31
Amit Dey27-Nov-00 10:31 
GeneralRe: Display selection in Button Controls Pin
Michael Dunn27-Nov-00 15:19
sitebuilderMichael Dunn27-Nov-00 15:19 
GeneralCode lines in VisualC(or VB) that add a new menu in Excell's menu bar Pin
26-Nov-00 22:58
suss26-Nov-00 22:58 
GeneralCustomizing MS Internet Explorer Pin
J.Sridhar24-Nov-00 19:55
J.Sridhar24-Nov-00 19:55 
GeneralRe: Customizing MS Internet Explorer Pin
ColinDavies24-Nov-00 20:55
ColinDavies24-Nov-00 20:55 
GeneralRe: Customizing MS Internet Explorer Pin
29-Nov-00 8:59
suss29-Nov-00 8:59 
GeneralLaunch a file when download is complete Pin
22-Nov-00 4:32
suss22-Nov-00 4:32 
GeneralC/C++ and JavaScript interaction Pin
21-Nov-00 20:05
suss21-Nov-00 20:05 
GeneralMicrosoft Project File Format MPX Pin
Andrew Postlewhite21-Nov-00 0:06
Andrew Postlewhite21-Nov-00 0:06 
GeneralSoftware Protection Pin
Dominic I. Holmes20-Nov-00 8:09
Dominic I. Holmes20-Nov-00 8:09 
GeneralRe: Software Protection Pin
J.Sridhar24-Nov-00 20:01
J.Sridhar24-Nov-00 20:01 
GeneralRe: Software Protection Pin
Masoud Samimi2-Dec-00 0:05
Masoud Samimi2-Dec-00 0:05 
GeneralFully owner draw interface Pin
14-Nov-00 4:28
suss14-Nov-00 4:28 
GeneralRe: Fully owner draw interface Pin
23-Nov-00 12:32
suss23-Nov-00 12:32 
GeneralRe: Fully owner draw interface Pin
24-Nov-00 0:12
suss24-Nov-00 0:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.