|
there is a pager class on codetools http://www.codetools.com/library/wfc.asp
however most pagers can be communicated with by dialling to the service provider and sending a alphanumeric message once connected. ie like you would if you was using a touch tone phone
Holy Handgrenade of Antioch instructions
|
|
|
|
|
I cannot figure out how to persistently change the clipping region of a child window control.
I have a rich edit control (non-mfc... created with CreateWindowEx), and I want to change the visible area of the control dynamically. There seem to be three approaches, and I cannot seem to figure out how to get any of them to work:
1. Call SetWindowRgn() on the child window control: this weirdly enough seems to make the specified region invisible, rather than visible, and is not persistent (the next InvalidateRect call re-draws the region.
2. Call SelectClipRgn(): this isn't persistent after the display context is released. The following code for example completely ignores my call to SelectClipRgn():
hdc = GetDC(hwnd);
rgn1 = CreateRectRgn(0, 0, 50, 50);
(void)SelectClipRgn(hdc, rgn1);
(void)ReleaseDC(hwnd, hdc);
hdc = GetDC(hwnd);
(void)GetClipBox(hdc, &WinRect);
rgn1 = CreateRectRgnIndirect((const RECT *)(&WinRect));
hbr = (HBRUSH) GetStockObject(WHITE_BRUSH);
(void)FillRgn(hdc, rgn1, hbr);
...
3. Intercept the WM_PAINT message of the control, and change the clipping region before the control is painted. The problem here is that I don't know how to intercept the child window WM_PAINT message without completely re-writing the control, and that doesn't seem to be the right solution.
Anyway, I love your site... first time I've logged onto CodeProject.com. I would appreciate any insight into how to clip a child control (a rich edit control in particular), but I have some buttons that I also want to clip in the same region.
Thank you,
Brian
Brian Rosenthal
Chief Technology Officer
MyBestHealth, Inc.
brosenthal@mybesthealth.com
|
|
|
|
|
Being completely confused, I wrote this test application I built to illustrate exactly what is happening to my code. It's a simple application that compiles by itself in VC6.0. A quick glance, and then running it, is meant to illustrate perhaps more in detail my confusion with setting the window region of a child control. I have marked three points in the code that can be either commented or not to produce results that to me were surprising and erratic. So, I guess my real question is to explain the results and tell me what I can do to get the richedit control in this example to have its region set properly.
Here is a quick description of the code, and then the actual source follows (you can just cut and paste into VC6.0, and it works). Sorry, I know the tabs didn't copy into the message, but I cannot figure out what to do to get them in there.
Simple WinProc:
I. WM_CREATE:
// Create a RichEdit Control
// Create a button
// Call ShowWindow() on each.
II. WM_COMMAND:
// If the button is clicked:
// 1. call SetWindowRgn(richedit) to set the region
// to only the top left.
// 2. (C. Call InvalidateRgn(...) on the window)
// 3. (D. Call InvalidateRgn(...) on the richedit control)
III. WM_PAINT:
// B. SendMessage(...WM_PAINT...) to both children, then return 0
// A. break;
As you can see, I note four places in the code which each produce a different behavior that confuses me. It's very easy to uncomment the proper lines and see the result.
Anyway, thank you very much in advance. If you would like me to clarify something, please send me e-mail at brosenthal@mybesthealth.com. Sorry if this is a stupid question. I feel like a dunce. Have been beating my head against the wall about this for a while. Anyway, here is the sourcecode that works in VC6.0:
I will post the sourcecode immediately following this on this thread (too long for one message)
|
|
|
|
|
#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);
}
|
|
|
|
|
It says in the documentation for SetWindowRgn:
"After a successful call to SetWindowRgn, the system owns the region specified by the region handle hRgn. The system does not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do not delete this region handle. The system deletes the region handle when it no longer needed."
In case 'A' below, if you comment out the break statement then you destroy the window region after the first WM_PAINT message, thus putting your display into an undefined state.
Jim
// 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; //if this is commented out, then lpab->hwndRichEditChatRegion is destroyed, violating rules for SetWindowRgn
// END WEIRD OUTCOME A
case WM_DESTROY:
DeleteObject(lpab->hwndRichEditChatRegion);
PostQuitMessage(0);
return 0;
}
|
|
|
|
|
|
When a button control is selected, a dotted line is drawn on that button to display its selected state. How do I do this for non rectangular buttons?
|
|
|
|
|
You can draw dotted lines using a pen with the PS_DOT style.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
I want to know if it's possible to add a new menu in Excell
or Word running an external program(in VC or VB) without using the Customize tool in Excell(or Word). If it's possible give me some code lines or some basic concepts or some web pages where a can find a way to solve my problem.
|
|
|
|
|
I have taken an internet account from an ISP. They gave me a IE browser, but the explorer revolving logo was replaced by their own. Further the standard toolbar had logos of the ISP throughout.Can anyone please tell me how to do such things?.
J.Sridhar
|
|
|
|
|
IE is fully customizeable !
I'm unsure of the method your ISP used to customize your Browser,
But maybe they,
1. Created an Avi
2. Registered a copy of IEAK (Internet Explorer Administration kit)
3. Mingled the two,( The Avi can be changed by altering a registry setting in the install process.)
4 the Toolbar buttons are probably all BHO's (Browser Helper Objects), these are just special self registering dlls. And the IEAK would handle the Install issues.
MS intentionally made IE fully customizeable, and I do mean "Fully".
If MS had slowed down there dispersal of IE and used 3rd party creators/distributors the wouldn't be having hassles with the DOJ now in regards to IE vs Navigator.
Anyhow I'm unsure where you learn more, I picked up my knowledge from a variety of sources,
MS
MSJ
MIND
CodeGuru
Here
DRDobbs
and associated NG's etc
Regardz
Colin Davies
Rotavator
|
|
|
|
|
Fully Customizable ?? How to we dynamically set the proxy edit fields for all the protocol types then, from inside some other Application??
|
|
|
|
|
Hello, what is the best way to launch an exe file after it is downloaded, without the user have to open the folder and execute it?
|
|
|
|
|
Hi!
I need a sample of code or some ideas or direction
about execution JavaScript from application writed
on C/C++. I want call procedure (or function) writed
on JavaScript from my C++ code and geting result
back. Is it possible? I think 'yes'.
|
|
|
|
|
Does anyone know where I can find a description of the file format for Microsoft Project MPX files ?
I'm looking to write a Pocket PC/Windows CE Project viewer importer and need the structure ?
|
|
|
|
|
Does anyone know of any lightweight software protection code out there (preferable C or C++)? I am looking to add some easy password unlocking mechanism to a shareware package. Some thing that allows timed demoe periods would be ideal.
I'm not really looking for industrial protection here, such as trying to prevent moving the software from machine to machine, or preventing reverse engineering. Just code for preventing certain features from being available from software that is downloaded, until they purchase or want a timed demo period.
Any thoughts would be appreciated.
Regards,
Dominic
|
|
|
|
|
Dear Mr.Dominic
Although I do not know any lightweight program to solve your problem, I sure know that any attempt to use a timed demo for a 30 day trial version sort or limited features sort will be useless because there are tools which canhelp people break your software mechanism in no time.Please see that you put some really strong s/w protection mechanism. Still, I will try to find out whether I can get something good for you.
Regards
J.Sridhar
|
|
|
|
|
Hi,
3 words! NEVER USE TIME PROTECTION!, IT FAILS!, ALWAYS!
One question?, Are you the author of the software yourself?
If yes, then you can surely code! so never use commercial protection programs coz they are always cracked!, they are the most targetted stuff! But instead use your own personal imagination and coding techniques to produce a matching, validating and authorising scheme.
I also recommend that you NEVER use Edit Boxes that are made within a resource editor, coz that's what they catch first!
Try making every thing that has to do with the protection W/O using the resource editor i.e. Create them at RunTime.
Also try not to have a keygenerating method, they get it!
All of us face the same when the final package is ready to be thrown into the market!
Good Luck!
Masoud
|
|
|
|
|
i'd like a tutorial that help to make a fully customized interface without anything that has the same properties as the common controls (i mean color, shape maybe)
For instance, i'm able to crush almost all windows controls except :
scrollbars , and popup / contextual menu's borders.
and maybe some other.
do u know a way to put ur own drawing and color (not system metric) in a window scrollbar (WS_HSCROLL / WS_VSCROLL) ??
even with flat scrollbars and new ie5 controls, can't do that. Why is the window os so closed to improvement !
|
|
|
|
|
i'd also like to see some tutorials on this subject. i've been looking for this kind of thing for a few weeks now and haven't really gotten anywhere. i'd like to suggest that if Thomas V knows how to alter most of the controls than maybe he could write some tutorials and share his knowledge with the rest of us.
as for why the Windows OS is so hard to alter it is probably that it was easier for Microsoft to keep with the same design they use and also so that they can make a large majority of applications look the same way thiers does. this is probably to make it easier for computer novices to learn new software.
|
|
|
|
|
Ok, i'll try to prepare the beginning of that tutorial. My main problem being i'm overwhelmed with work, so it will take me some time.
|
|
|
|
|
Hi there,
what about your tutorial ? I think I could give you a few tips building up applications
without using standard-classes. I have done a lot of work developing classes to handle
bitmap-buttons, button-groups and so on, owner-drawn-displays ...
And believe me - they are fast ( only Win32-API used )
So if you need some help writing a good tutorial - just write a short mail and I will see
if I could do something for you!
Greatings Mario ///
---------------------
www.klangwerker.de
mario@klangwerker.de
---------------------
|
|
|
|
|
modem - called number question
reading about web pages reconnecting your modem to any exotical country with big phone costs
i'm looking for possibility to get/display actualy called phone number (normaly nr. of my local provider)
(or any fw sw knowing it)
thanks
t!
|
|
|
|
|
|
Hi everybody,
does anybody know how to get a tooltip on a disabled activex control?
I'm using the solution described in MSDN: "HOWTO: Add Tooltips to ActiveX Controls" (Article ID: Q141871), but the tooltips only work if the control is enabled.
Thanks in advance!
Michael
|
|
|
|
|