|
WinMain should give you an hInstance you can use.
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
|
|
|
|
|
i don't know what is happening now, i have used hInstance AS delivered by winmain, but my createwindowex is stilling failing and when i call getlasterror, i get a code of 0 which apparently means success, this is extraordinarily frustrating, thank you for your help so far, but this is just rediculousl annyoing, thank yuou for any further help
|
|
|
|
|
Can you post some actual code or send it to me?
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
|
|
|
|
|
this is my create window method:
bool GLWindow::CreateGLWindow(HINSTANCE hInstance //this is hInstance passed by WinMain)
{
ofstream emsg ("ERROR.txt"); //this is where i have been putting my errors
GLuint PixelFormat;
DWORD dwExStyle;
DWORD dwStyle;
RECT WindowRect;
WindowRect.left = (long)0;
WindowRect.right = (long)m_aResolution[0]; WindowRect.top = (long)0;
WindowRect.bottom = (long)m_aResolution[1];
m_hInstance = hInstance;
WNDCLASSEX l_wc =
{ sizeof(WNDCLASSEX),
CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW | CS_OWNDC,
(WNDPROC) WndProc,
0,
0,
m_hInstance,
LoadIcon(NULL, IDI_WINLOGO),
LoadCursor(NULL, IDC_ARROW),
NULL,
NULL,
m_StrTitle,
LoadIcon(NULL, IDI_WINLOGO),
};
if (!RegisterClassEx(&l_wc))
{
emsg << GetLastError();
MessageBox(NULL,"Failed To Register The Window
Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
/*********************************my class registers fine, no problem at all*********************/
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle=WS_OVERLAPPEDWINDOW;
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
if (!(m_hWnd=CreateWindowEx(dwExStyle, m_StrTitle, m_StrTitle,
dwStyle |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0, 0, WindowRect.right-WindowRect.left,
WindowRect.bottom-WindowRect.top,
NULL,
NULL, m_hInstance, this)))
{
/*************************************************************************************************
this is where the failure is, but the error code that gets printed is zero (which is enumerated as ERROR_SUCCESS) which i don't get at all, i don't know if i am somehow getting the wrong error code or what!!
*************************************************************************************************/
emsg << GetLastError();
emsg.close();
this->KillGLWindow();
MessageBox(NULL,"Window Creation Error","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
****NOTE: i nocked off the rest of the code because it works, and it doesn't do anything but take up a lot of space in this post.
Your help so far has been great, thank you for your continued support
-Matthew
|
|
|
|
|
From the CreateWindowEx documentation:
This function typically fails for one of the following reasons:
*an invalid parameter value
*the system class was registered by a different module
*the WH_CBT hook is installed and returns a failure code
*the window procedure fails for WM_CREATE or WM_NCCREATE
Check your params and your wndproc.
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
|
|
|
|
|
Add this line to your code
wc.style = CS_GLOBAL;
//initial other fields
RegisterClassEx(&wc);
|
|
|
|
|
CS_GLOBAL isn't a field in style, i can't set it to that, it tells me 'CS_GLOBAL': undeclared identifier
also, for some reason, i am being told that the paramter is incorrect when i try and register my class
|
|
|
|
|
In fact it's CS_GLOBALCLASS,I've forgotten a word.
When you call CreateWindow or CreateWindowEx,the function will compare the hInstance you passed to it to the hInstance of the WNDCLASSEX hInstance field.
Set the style field to CS_GLOBALCLASS tells the function that it should not compare these two values.
|
|
|
|
|
Hello all,
I created a Month calendar control into my form, and I want to use it as a date picker, so when the user selects a date, I will fill other CEdit controls with the date selected.
But I realize that within MCN_SELECT, the value associated with my Calendar Control, gets the wrong date.
void CPlanmView::OnSelectMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult)
{
// Users Selects a Date, so MCN_SELECT triggers this.
// User selected October 31, 2003 but returns
// Feb,10,2004
*pResult = 0;
UpdateData();
m_DayPlm.Format("%d",m_CalendarVal.GetDay());
m_MonthPlm.Format("%d",m_CalendarVal.GetMonth());
m_YearPlm.Format("%d",m_CalendarVal.GetYear());
UpdateData(FALSE);
}
I have also seen the sample provided in the msdn, and it has the same problem, for this control.
Any Ideas on how to workaround this issue.
Best,
-Alfredo
|
|
|
|
|
I just found the answer for this problem
Microsoft Knowledge Base Article - 235355
I post it here for reference in case somebody else has to deal with this.
The Microsoft article says this behaviour is by design, and SYSTEMTIME should be used instead of CTime class
Best,
Alfredo
|
|
|
|
|
I need an accounting program that is able to keep track of inventory, orders, account receivable and others.
I would need the ocde in order to create custom fit program.
Are this type of programs available including the source. What are my best alternatives?
Thank you
|
|
|
|
|
Hi All.
Why does Windows need a registry ? (Or at least: Why does Windows let programmers stuff with it ?)
I can't see why any program settings can't be stored in a file within the directory that the app is installed to. It can just load that file and read what it is supposed to do each time it runs.
It amazes me that this practice is so common and even promoted (Even here on CP). If I want my computer to behave differently: I'll tell it...not some scumbag programmer who thinks they know better!
Maybe there is a need for a "Read-Only" Windows registry for windows settings to be passed to the program.
Anyone ? Discussion ?
(Quite a rant, but it didn't belong in the Lounge).
Cheers
If sex is a pain in the ass, then you are doing it all wrong!
|
|
|
|
|
wogerdoger wrote:
Why does Windows need a registry ?
Windows needs a registry to store settings that are generally not changed often. Have you ever worked on Linux? Linux has thousands of configuration files stored all over the place which makes it a real pain to configure but this is buy design. Since companies can not sell the software but they can sell the support. They have to make it as hard to setup as you can get away with so there is a reason to use the very expensive support services.
John
|
|
|
|
|
John M. Drescher wrote:
Have you ever worked on Linux? Linux has thousands of configuration files stored all over the place which makes it a real pain to configure but this is buy design.
Indeed, GNOME and GNOME-based apps under Unix now store application data in a central registry called gconf. Apps can "listen" to their gconf keys and be notified when the user (or another app, like a preferences applet) changes the value. Seems the GNOME people at least saw the advantages of a centralized, cacheable, uniform-format configuration system
- Mike
|
|
|
|
|
Thanks for the info. I did not know that about GNOME.
John
|
|
|
|
|
The registry is also a single point of failure.
--
The coolest game in the world: NHL Hockey[^]
|
|
|
|
|
Lounge *coughs*
I agree partially...I always thought polymorhpic executables would be a better solution still. That way program registry data goes where the program goes. However in defense of Windows registry, I think under some circumstances it's required. You need a standard single location so programs can commumicate if required. I would think that Office suite would be a good example, in that Outlook can probably check the registry for Word's existance and see if spell check is installed if so then enable spell checker for outlook. I don't know if this is how they really accomplish tasks or if they use OLE or something, but it serves as an example of what I mean. If programs stored all data in specialized data files 2 programs that are not related in any way would have a hard time communicating. Atleast it gives you a place to start looking for program INI stuff
Just my opinion
wogerdoger wrote:
If sex is a pain in the ass, then you are doing it all wrong!
Thats great
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Hockey wrote:
However in defense of Windows registry, I think under some circumstances it's required. You need a standard single location so programs can commumicate if required. I would think that Office suite would be a good example, in that Outlook can probably check the registry for Word's existance and see if spell check is installed if so then enable spell checker for outlook. I don't know if this is how they really accomplish tasks or if they use OLE or something, but it serves as an example of what I mean.
Good point.
John
|
|
|
|
|
As a programmer I design my software to use both registry and ini files. For the things that the user may need to change or move from pc to pc I put it in ini files. For the small items (less than a KB of data) that the user will never change directly I put in the registry.
John
|
|
|
|
|
I would much rather use the registry because:
all aspects of the computer are stored in one central place.
it is way more hierarchical that INI files; can store more data, and different types of data.
the registry can be secured.
That said, INI files have the same type(s) of arguments. Each are a tool for solving a problem, and like most tools, they can be a benefit, or they can abused and become a hindrance.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Isn't it the purpose of "Application Data" ( or "Local Settings\Application Data" under "Document and Settings" ) the new preferred place to place user settings ?
Also, having only a part of the registry, HKEY_CURRENT_USER, writable should limit the damages.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
wogerdoger wrote:
I can't see why any program settings can't be stored in a file within the directory that the app is installed to
You mean like .INI files? The files that are easy for clueless users to go and mess up, thereby breaking the program and frustrating said user?
MS moved program settings to the registry to prevent that sort of thing from happening.
--Mike--
Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
Michael Dunn wrote:
The files that are easy for clueless users to go and mess up, thereby breaking the program and frustrating said user?
Lol! I think it would be more dangerous if a user ran regedit instead..
--
The coolest game in the world: NHL Hockey[^]
|
|
|
|
|
Jörgen Sigvardsson wrote:
I think it would be more dangerous if a user ran regedit instead..
Yep, that's why you won't find a Registry Editor shortcut on the Start menu.
I can just imagine it now...
<clueless-user>
hmm, I'm running low on space. What can I do to get rid of some of my old programs? hmm... "Registry editor" Let me see what's there. *clickety*
Aitch-kee-local-machine. Is that like my hard disk? Open it up... ah, "software" that must list the software I have on my hard disk. Open it... HOLY CRAP I have all this software installed? *deletes* There we go.
</clueless-user>
--Mike--
Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer.
-- Michael P. Butler in the Lounge
|
|
|
|
|
And what about all them aitch-kee-classes?
:a-million-voices-screaming-out-in-pain:
--
The coolest game in the world: NHL Hockey[^]
|
|
|
|
|