Click here to Skip to main content
15,892,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: base64 encodeing Pin
Johnny ²11-May-03 22:15
Johnny ²11-May-03 22:15 
GeneralRe: base64 encodeing Pin
Mazdak11-May-03 22:25
Mazdak11-May-03 22:25 
GeneralTrapping the escape key Pin
Steve Messer11-May-03 21:24
Steve Messer11-May-03 21:24 
GeneralRe: Trapping the escape key Pin
JensB11-May-03 21:42
JensB11-May-03 21:42 
GeneralRe: Trapping the escape key Pin
Steve Messer12-May-03 18:48
Steve Messer12-May-03 18:48 
GeneralRe: Trapping the escape key Pin
Cedric Moonen11-May-03 21:43
Cedric Moonen11-May-03 21:43 
GeneralRe: Trapping the escape key Pin
Steve Messer12-May-03 5:56
Steve Messer12-May-03 5:56 
GeneralSome problems about superclassing Pin
boytan11-May-03 21:18
boytan11-May-03 21:18 
i edited a program to superclassing the editbox.
The superclassing succeeded,but when i create the superclassed editbox ,there is a problem:
i first create the superclassed editbox in the window's
wm_create message,but the editbox can not be showed out.
But it can be showed out after i move it to the winmain.
how strange it is.

Anyone can tell me why?
thanks.

<br />
#include<windows.h><br />
#include<tchar.h><br />
<br />
#define IDC_SUPERCLASS1 1<br />
<br />
static HWND hsuperedit1;<br />
<br />
WNDPROC g_editwndOrg;<br />
static LPCTSTR sz_editsuperclass=TEXT("SuperclassEdit");<br />
<br />
LRESULT WINAPI EditSuperclassWndProc(HWND hedit,UINT msg,WPARAM wParam,LPARAM lParam);<br />
<br />
LRESULT WINAPI WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)<br />
{<br />
	int cx,cy;<br />
	switch(msg)<br />
	{<br />
	case WM_CREATE:<br />
                  hsuperedit1=CreateWindow(sz_editsuperclass,NULL,ES_AUTOHSCROLL|ES_LEFT|ES_MULTILINE|WS_CHILD|WS_VISIBLE,100,200,300,400,hwnd,(HMENU)IDC_SUPERCLASS1,HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),NULL);<br />
		return 0;<br />
	case WM_DESTROY:<br />
		PostQuitMessage(0);<br />
		return 0;<br />
	}<br />
	return DefWindowProc(hwnd,msg,wParam,lParam);<br />
}<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR lpCmdLine,int nShowCmd)<br />
{<br />
	static LPCSTR szClassName="Show Time";<br />
	WNDCLASSEX wc_edit;<br />
	WNDCLASSEX wc;<br />
<br />
	ZeroMemory(&wc,sizeof(wc));<br />
	wc.cbClsExtra =0;<br />
	wc.cbSize =sizeof(WNDCLASSEX);<br />
	wc.cbWndExtra =sizeof(LONG);<br />
	wc.hbrBackground =(HBRUSH) GetStockObject (COLOR_BACKGROUND) ;<br />
	wc.hCursor =LoadCursor (NULL, IDC_ARROW);<br />
	wc.hIcon =NULL;<br />
	wc.hIconSm =NULL;<br />
	wc.hInstance =hInstance;<br />
	wc.lpfnWndProc =WndProc;<br />
	wc.lpszClassName =szClassName;<br />
	wc.lpszMenuName =NULL;<br />
	wc.style =CS_HREDRAW|CS_VREDRAW;<br />
<br />
	ATOM atomclass=RegisterClassEx(&wc);<br />
	if(atomclass==INVALID_ATOM)<br />
	{<br />
		MessageBox(NULL,"RegisterClass Error","RegisterClass Error",MB_OK);<br />
		exit(1);<br />
	}<br />
<br />
	HWND hwnd=CreateWindowEx(NULL,szClassName,0,WS_OVERLAPPEDWINDOW,<br />
		0,0,500,650,NULL,NULL,hInstance,NULL);<br />
<br />
	ZeroMemory(&wc_edit,sizeof(wc_edit));<br />
	GetClassInfoEx(NULL,"edit",&wc_edit);<br />
	g_editwndOrg=wc_edit.lpfnWndProc;<br />
	wc_edit.lpszClassName =sz_editsuperclass;<br />
	wc_edit.hInstance =hInstance;<br />
	wc_edit.lpfnWndProc =EditSuperclassWndProc;<br />
	wc_edit.cbSize =sizeof(WNDCLASSEX);<br />
<br />
	ATOM atomclass_edit=RegisterClassEx(&wc_edit);<br />
	if(atomclass_edit==INVALID_ATOM)<br />
	{<br />
		MessageBox(NULL,"RegisterSuperClass Error","RegisterSuperClass Error",MB_OK);<br />
		exit(1);<br />
	}<br />
<br />
	ShowWindow(hwnd,SW_SHOW);	<br />
	UpdateWindow(hwnd);<br />
//      if the createwindow was moved from wm_create to <br />
//	here(in WinMain()),the editbox can be showed out.<br />
//	hsuperedit1=CreateWindow(sz_editsuperclass,NULL,ES_AUTOHSCROLL|ES_LEFT|ES_MULTILINE|WS_CHILD|WS_VISIBLE,0,0,100,200,hwnd,(HMENU)IDC_SUPERCLASS1,(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE) ,NULL);<br />
<br />
<br />
	MSG msg;<br />
	while(GetMessage(&msg,NULL,NULL,NULL))<br />
	{<br />
		TranslateMessage(&msg);<br />
		DispatchMessage(&msg);<br />
	}<br />
	return msg.wParam ;<br />
}<br />
<br />
LRESULT WINAPI EditSuperclassWndProc(HWND hedit,UINT msg,WPARAM wParam,LPARAM lParam)<br />
{<br />
	LRESULT lResult;<br />
	BOOL fCallOrgProc=TRUE;<br />
	switch(msg)<br />
	{<br />
	case WM_CHAR:<br />
		if(wParam=='a')<br />
		{<br />
			fCallOrgProc=FALSE;<br />
		}<br />
		break;<br />
	}<br />
	if(fCallOrgProc)<br />
	{<br />
		lResult=CallWindowProc(g_editwndOrg,hedit,msg,wParam,lParam);<br />
	}<br />
	return lResult;<br />
}<br />
<br />

QuestionHow to locate an adress to write in a file? Pin
fineo11-May-03 18:40
fineo11-May-03 18:40 
AnswerRe: How to locate an adress to write in a file? Pin
Hari Krishnan (Noida)11-May-03 18:58
Hari Krishnan (Noida)11-May-03 18:58 
GeneralGDI on win98 & win2000! Pin
wxjlb11-May-03 17:39
wxjlb11-May-03 17:39 
QuestionHas my compiler gone mad? Pin
georgiek5011-May-03 13:36
georgiek5011-May-03 13:36 
AnswerRe: Has my compiler gone mad? Pin
Tim Smith11-May-03 14:36
Tim Smith11-May-03 14:36 
GeneralRe: Has my compiler gone mad? Pin
georgiek5012-May-03 1:01
georgiek5012-May-03 1:01 
GeneralRe: Has my compiler gone mad? Pin
Tim Smith12-May-03 1:16
Tim Smith12-May-03 1:16 
GeneralRe: Has my compiler gone mad? Pin
georgiek5012-May-03 9:49
georgiek5012-May-03 9:49 
GeneralInternetOpenUrl Pin
georgiek5011-May-03 12:24
georgiek5011-May-03 12:24 
GeneralRe: InternetOpenUrl Pin
J. Dunlap11-May-03 13:01
J. Dunlap11-May-03 13:01 
GeneralRe: InternetOpenUrl Pin
georgiek5011-May-03 13:08
georgiek5011-May-03 13:08 
GeneralAccelerator keys and edit boxes Pin
User 17962311-May-03 11:21
User 17962311-May-03 11:21 
GeneralRe: Accelerator keys and edit boxes Pin
Bartosz Bien11-May-03 13:15
Bartosz Bien11-May-03 13:15 
QuestionIs there an equivalent function to "DoModal()" for modeless dialogs? Pin
julych11-May-03 10:07
julych11-May-03 10:07 
AnswerRe: Is there an equivalent function to "DoModal()" for modeless dialogs? Pin
Nick Parker11-May-03 10:47
protectorNick Parker11-May-03 10:47 
AnswerRe: Is there an equivalent function to "DoModal()" for modeless dialogs? Pin
John M. Drescher12-May-03 5:01
John M. Drescher12-May-03 5:01 
Generalproblem with ONDRAW Pin
aguest11-May-03 9:15
aguest11-May-03 9:15 

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.