|
choadvach wrote: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
To the entry point of an application, i dont think any parameters are passed in to it. That means the HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow are all junk values.
May you can try like this
int WINAPI WinMain()
{
HINSTANCE hInstance = GetModuleHandle(NULL);
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLG1), NULL, DialogProc);
return 0;
}
And let me know the result.
|
|
|
|
|
Thanks a ton, this worked perfectly! All this time it was so simple and I was just blowing my mind over nothing.
|
|
|
|
|
Naveen.R wrote: That means the HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow are all junk values
What do you mean by this, these are junk values?
|
|
|
|
|
I mean kernel32.dll will not pass those parameters to the application entry point. Have you checked how an application entry point is? check the WinMainCRTStartup function. You can find how that function calls the winmain of an application.
|
|
|
|
|
Hi all,
How to use edit box.I want to enter some string in the edit box and pass it as an argument to some function.
|
|
|
|
|
You can use of SetWindowText for set text and for retrieve text use of GetWindowText .
|
|
|
|
|
Hi, I have a windows service program where I use it to run another program using the ShellExecute command. However, I dont know how to terminate the spawned program as I am new to VC++ programming.
Anyone has any idea?
Moonis
|
|
|
|
|
|
My application takes longer and longer to compile and run. I program in C++ Builder 2006. Each time I change something in my apps' Core bpl, it takes about 5 minuets to compile and up to 2 minuets to link. I waste about 1 hour a day waiting for my code to compile!
Anybody have some pointers on how to optimize this kak process? Is it my header hierarchy or what influences the compiling and linking? -besides the lines of code.
Thanks
|
|
|
|
|
The only thing I can think of is that it's your header file inclusion, each time you change the definition in a header file all the source files that include it will get reprocessed, and depending on your compiler multiple inclusion of header files from different sources indirectly will only increase the preprocessing time. Only include the header files in the source that actually need them! Also do NOT have your header file include other header files, sometime you can't get away from this but most of the time developer are plain freaking lazy and will shover all kind of crap they don't need, or they have a global header file that includes other header, etc.
The other thing you could do is separate your code and make it more modular and isolate functions, API, etc. Then you only have to rebuild (hopefully) that one module and link with it everywhere else saving time?
Last solution, and the best!!!! Don't make changes to the code and then you don't need to worry about them pesky compiler problem!!!
5 min + 2 min is nothing to complain about man!!! Some projects I know have taken much much longer to build
|
|
|
|
|
It could be something in your header file hierarchy. Is a pre-compiled header option available with Builder ?
One thing I am now in the habit of doing (and I get some flak for) is a more proactive form of header inclusion guards. I use an included definition of the form :
#ifndef _INCLUDEFILE_H
#define _INCLUDEFILE_H
...
then I also put this in comments for easy cutting and pasting :
and I use this form whenever I place an include statement in a header whether I am including one of mine or one from the compiler. Always !
Also - I usually take this even a bit farther. I make it a fatal error if a file is repeatedly included and this helps track them down quicker. This is done as follows :
#ifndef _INCLUDEFILE_H
#define _INCLUDEFILE_H
#else
#error repeated include of this file
#endif
You can comment off the #else and the #error if you don't want that to be a fatal error.
In the past I have made the conversion to this style very quickly because it's easy to do and it has always resulted in significant improvements in compile time for me. In fact, generally speaking, the larger the project the larger the speed-up that I have seen.
Now, this is only a compile time improvement so it does not address your link time issue. There are lots of variables involved in link time. Efficiency of the linker, amount of available memory, and hard drive speed are three biggies. Unfortunately I don't have any easy answers for this.
|
|
|
|
|
Cool maneuver. Here I always thought that it's less efficient if you have one Include header.
Thanks!
|
|
|
|
|
Also...
You aren't doing full builds every time, are you?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Yeah, I'm working in my Core at this time. It has alot of different helper forms, -casses and automation functions. I have to recompile the whole shabang, even if I only added a ShowMessage for debugging - The Builder Debugger crashes alot during step-trough variable inspection and i've lost tooo many code. (thanks to Builders bugs. )
|
|
|
|
|
Things to look into:
1. Precompiled headers.
2. Unneeded include files.
3. Using abstract base classes as interfaces to avoid having to include class definitions.
Steve
|
|
|
|
|
Stephen Hewitt wrote: 3. Using abstract base classes as interfaces to avoid having to include class definitions.
Yeah this is what i want to hear. I was never sure. Currently my design lacks abstraction. But now - implementing and converting candidate classes will mean a huge design change.
Thanks!
|
|
|
|
|
ok very simple: i am trying to read a line of text from a text file.
here is the text file:
dg_bead<br />
-15<br />
5<br />
5<br />
1<br />
0
here is the code that reads in the first line:
ifstream dg_scenario::dg_replay("replay.txt",ios::in);<br />
char tool_name[256];<br />
dg_replay.getline(tool_name,256);
i put a break point in this line:
dg_replay.getline(tool_name,256);
the app triggered the breakpoint and i stepped through it.
then i checked the value of tool_name and it was:
0x0222a978 ""
i checked all the indices of the array and they were all zero!
this is a very simple task - how should i resolve it.
P.S. i need to use the tool_name[256] char array as a char* to pass it as a parameter through a function that only accepts char*. is there a way i can convert the value stored in tool_name[256] (once the above prob is fixed) into a char* that stores the same value.
thx in advance.
--
dg
|
|
|
|
|
What happens if you try this?
ifstream dg_scenario::dg_replay("replay.txt",ios::in);
char tool_name[256];
if (dg_replay.is_open())
dg_replay.getline(tool_name,256);
or
ifstream dg_scenario::dg_replay("replay.txt",ios::in);
char tool_name[256];
if (dg_replay.good())
dg_replay.getline(tool_name,256);
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
nice to see you're helping kiddies cheat on their homework
|
|
|
|
|
I'm gullible like that!
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
genius - it works.
thanks!
--
dg
|
|
|
|
|
moonraker928 wrote: genius - it works.
I don't know why - I only added a line to check if the file was opened successfully
Glad it works!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Is this a homework assignment? did the prof say you need to use tool_name limited to only 256 chars ... shame on you, I will not be a part of this!!!
|
|
|
|
|
|
hi all.
my app is throwing an unhandled exception - the problem appears to be caused when istream adds a null character at the end of a char array when the getline function is called
here is the code:
i initialized the tool_name in this line:
simpleTask.cpp
char* tool_name = "";
i put a breakpoint here:
simpleTask.cpp
dg_replay.getline(tool_name,256);
when i ran the app, the breakpoint was triggered. i stepped in and it brought me to this line:
istream.cpp
*_Str = _Elem(); // add terminating null character
at this time, an unhandled exception is thrown.
--
dg
|
|
|
|