Click here to Skip to main content
15,922,315 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: information on pixel of a picture Pin
ThatsAlok6-Feb-05 23:39
ThatsAlok6-Feb-05 23:39 
GeneralError in put_text Pin
cj_rahul6-Feb-05 23:22
cj_rahul6-Feb-05 23:22 
GeneralRe: Error in put_text Pin
Mike Dimmick6-Feb-05 23:29
Mike Dimmick6-Feb-05 23:29 
GeneralDifferent fonts in CTreeView Pin
bilas6-Feb-05 23:16
bilas6-Feb-05 23:16 
GeneralRe: Different fonts in CTreeView Pin
Mike Dimmick6-Feb-05 23:23
Mike Dimmick6-Feb-05 23:23 
GeneralRe: Different fonts in CTreeView Pin
bilas6-Feb-05 23:33
bilas6-Feb-05 23:33 
GeneralRe: Different fonts in CTreeView Pin
bilas7-Feb-05 0:40
bilas7-Feb-05 0:40 
GeneralCreateWindow fails Pin
Member 14932146-Feb-05 23:01
Member 14932146-Feb-05 23:01 
I am in the process, of creating a simple application.
in simple C++ (No MFC, bits of STL).

I basically Have one class . the Main Class (Similar to MFC)
on initialization of Main Class. The Window should be created as in the Main Constructor.

If I do like this, The Application fails while Creating The Window.
The Class Registers, The CreateWindow Fails at RunTime. with the Error, The Memory could not be written.

However I bring the CreateWindow() Function within the WinMain The Code works fine.
Can you tell me Why is this so???


My WinMain runs something like this
Main* the_app;
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int nCmdShow)
{
the_app = new Main(hInstance,nCmdShow);

BOOL bRet;
while( (bRet = GetMessage( &(the_app->msg), NULL, 0, 0 )) != 0 )
{
if (bRet == -1)
{
}
else
{
TranslateMessage(&(the_app->msg));
DispatchMessage(&(the_app->msg));
}
}
return (int)((the_app->msg).wParam);
}

while the Main class has something like this
class Main
{
public:
HINSTANCE hInstance;
HDC Hdc;
// list<drawable_object> D_objects;
HWND Hwnd;
MSG msg;
WNDCLASSEX wc;
HICON hi;
ATOM main_item;


Main(HINSTANCE,int);
void Destroy();
void update_HWND(HWND with_this);
};

Main::Main(HINSTANCE Hinstance,int nCmdShow)
{
hInstance = Hinstance;
hi = LoadIcon(hInstance,"ICON1");
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = hi;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 );
wc.lpszMenuName = "IDR_MY_MENU";
wc.lpszClassName = "MainWClass";
wc.hIconSm = NULL;

if (!(main_item=RegisterClassEx(&wc))){
MessageBox(GetForegroundWindow(),"Register Class HAs Failed","INFO",MB_OK);
}

Hwnd = CreateWindow((LPCTSTR)main_item,"Shri-Ganesha",WS_CAPTION|WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,NULL,NULL);
if (!Hwnd)
{
MessageBox(GetForegroundWindow(),"Create Window has failed","INFO",MB_OK);
exit(1);
}

ShowWindow(Hwnd,nCmdShow);
}
GeneralRe: CreateWindow fails Pin
ThatsAlok6-Feb-05 23:19
ThatsAlok6-Feb-05 23:19 
GeneralRe: CreateWindow fails Pin
Member 14932147-Feb-05 0:35
Member 14932147-Feb-05 0:35 
GeneralUpdateCommandUI problem Pin
Ro_land6-Feb-05 22:38
Ro_land6-Feb-05 22:38 
GeneralRe: UpdateCommandUI problem Pin
Roger Allen7-Feb-05 3:59
Roger Allen7-Feb-05 3:59 
GeneralRe: UpdateCommandUI problem Pin
Ro_land7-Feb-05 19:00
Ro_land7-Feb-05 19:00 
GeneralLSP Problem Pin
X20406-Feb-05 21:32
X20406-Feb-05 21:32 
GeneraljosephSDK Listview Pin
tijo_joseph@rediffmail.com6-Feb-05 21:31
susstijo_joseph@rediffmail.com6-Feb-05 21:31 
Generalport on/off checking after my program is slow Pin
vc-programmer-6-Feb-05 21:06
vc-programmer-6-Feb-05 21:06 
GeneralRe: port on/off checking after my program is slow Pin
Tom Wright7-Feb-05 11:43
Tom Wright7-Feb-05 11:43 
GeneralRe: port on/off checking after my program is slow Pin
vc-programmer-7-Feb-05 16:12
vc-programmer-7-Feb-05 16:12 
GeneralRe: port on/off checking after my program is slow Pin
Rick Crone9-Feb-05 11:12
Rick Crone9-Feb-05 11:12 
GeneralRe: port on/off checking after my program is slow Pin
vc-programmer-9-Feb-05 20:43
vc-programmer-9-Feb-05 20:43 
GeneralXML creation in vc++ using MSXML Pin
cj_rahul6-Feb-05 20:19
cj_rahul6-Feb-05 20:19 
GeneralRe: XML creation in vc++ using MSXML Pin
ThatsAlok6-Feb-05 20:43
ThatsAlok6-Feb-05 20:43 
General[Q] ActiveX -&gt; MFC control... Pin
rbid6-Feb-05 19:33
rbid6-Feb-05 19:33 
QuestionHow to add Modes in Display setings on windows98 Pin
Anonymous6-Feb-05 18:26
Anonymous6-Feb-05 18:26 
GeneralOpen with... Pin
Anonymous6-Feb-05 17:49
Anonymous6-Feb-05 17:49 

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.