|
|
No sir, actually when I set bitmap to property page it appears but not from 0,0 pixel but from like 5,5 pixel.
|
|
|
|
|
I am in problem with static variable.Please help me.
Program:
file1.h
int x = 10;
file2.cpp
#include "file1.h"
#include "stdio.h"
extern int x;
void main() {
printf("%d",x);
}
o/p: Error(Unresolved external symbol)...
As per my knlowledge is consern I know to access x I have to use extern.But it is giving error.I want to know whts there reseaon?
Compiler: vc++ 2005(8.0ver)
|
|
|
|
|
Technically "x" isn't an extern the way you've done it. You don't need the extern keyword in file2.cpp. Extern is meant to imply that the variable is defined externally to the files that are referencing it. Since you've defined x in the header and then included it it isn't defined externally.
Also you aren't using any static variables whatsoever in the example you've provided. I think you really need to find a basic C primer on the net talking about extern and static variable and read through that since you are missing some fundemental understandings. No point writing code until you clear that up.
|
|
|
|
|
Please modify the code by which I can access x declared in file1.h in file2.cpp.
Again give me one fantastic example of usages of keyword extern.Please don't give example like below...
extern int x;
fun() {
printf("%d", x);
}
int x = 80;
fun2(){
printf("%d", x);
}
|
|
|
|
|
file1.c
-------
int counter = 1;
file2.h
-------
extern int counter;
file2.c
---------
#include "file2.h"
void countToTen()
{
while (counter <= 10) {
printf("%d\n", counter++);
}
}
Notice that counter is defined in the file.c file hence to access it we need to define it as external to our file2.c file that uses it. Hope that gives you an idea about extern vars. Similar principle applies to extern functions.
You really need to read some books on the topic.
|
|
|
|
|
Thanks a lot. It'd be great if you are sending me some useful links.
|
|
|
|
|
Does anyone have instructions on how I would go about automatically adding an auto-increment build number each time the app is compiled so that it shows up in the apps titlebar?
For eg say I have an app called Browser. First time I compile my app the title would be Browser V1.0 (build 1). I compile it again and it would be Browser V1.0 (build 2) etc.
I don't want to have to manually go into the dialog editor and change it for each compile and neither do I want to have to update a variable by hand each time for compile.
Any help would be appreciated. The language is VC++ and I'm using Visual Studio 2009.
Thanks!
PS: I'd like something that doesn't require me to alter or add stuff to the registry. I want to be able to grab the project folder, copy it to another machine and have it work straight off the bat without going through registering 3rd party dll's in the registry each time I move the source code to another PC. I found http://www.codeproject.com/KB/cpp/autobuildnumber.aspx but don't like the fact I need to go through a setup procedure that goes outside of the compiler.
Also most discussions about the topic date back 6+ years. I'm hoping MS added some functionality into VS2009 to maybe make the process simpler, more native.
modified on Sunday, October 5, 2008 8:05 AM
|
|
|
|
|
What I use is the Build Date held in the PE Header. you get that by opening your exe or dll as a binary file for reading, and wade through the headers. These headers are declared in "Windows.h". I do this once in InitInstance(), and store the value in a global time_t. You can then choose in your AboutDlg to just show this as a 'Secret' number, or format it out as a Build Date and Time. Furthermore, this info is also immediately available to your install routines, and is available for all binaries, whether built by you with this in mind, or otherwise.
regards
Bram van Kampen
|
|
|
|
|
Thanks though I would prefer something a bit easier though. Interesting idea though. I might just write a little app that increments a build number in a .h file and call that per compile. Then include that in the app for use. Shouldn't be too hard. I'm amazed MS after all these years hasn't provided what is a fundemental tool for any developer releasing images for testing.
|
|
|
|
|
montiee wrote: I'm amazed MS after all these years hasn't provided what is a fundemental tool for any developer releasing images for testing.
So am I, but well, my voting shares in microsoft are insufficient to force the issue.
montiee wrote: I would prefer something a bit easier though. Interesting idea though. I might just write a little app that increments a build number in a .h file and call that per compile. Then include that in the app for use
Well, thought of that, even wrote it. Would not use a .h file target for that though, try to line it in as a 'Pre Compile Step'
montiee wrote: Shouldn't be too hard.
That's what I thought. Success!
BTW it is very very easy to write a piece of code to get the link stamp of an exe.
Bram van Kampen
|
|
|
|
|
Hello everyone,
I asked question about debugging native code before -- mode details it is about optimized release mode x64 code which will use register to store variable which will block debugger from monitoring the variable value.
Today, I debugged a managed program, also in release build for the managed program, but I do not compile it with x64, and it is for "Any CPU". I met with the same issue and when see the assembly code, it has the same pattern that putting some variable in register prevents debugger to see its value.
My question is, I am not 100% confident enough (since the build is not for x64 release, but for "Any CPU" release, different build option from the native code issue before) and I want to confirm with you the same issue happens not only in native code in x64 release mode, but also in managed code in release "Any CPU" mode?
thanks in advance,
George
|
|
|
|
|
I am using MFC's CDialog derived class to do some lengthy task. I use a button to trigger the process. The problem I am having is: after I click the button, the lengthy task begins. However, after I switch to other programs, the dialog won't respond my click on it until the task is done.
Is there any way I can do to get rid of the problem.
|
|
|
|
|
It's normal: your application has only one thread, in which the Windows messages are processed (mouse click, click on button, ...). So, if in this thread you start a lenghty process, Windows messages are not processed anymore and your GUI will freeze (not able to respond to any messages, event not the WM_PAINT message).
The solution is to start this process in a separate thread and to keep the main dialog informed about the status by sending custom messages to it.
I suggest you read this excellent article[^], it's worth the time you will take to read it.
|
|
|
|
|
I had the same issue and found a simple solution. In the process/task that you are triggering from this dialog, insert the following code so it gets called periodically while that process/task progresses.
MSG msgs;
while( ::PeekMessage( &msgs, NULL, 0, 0 , PM_NOREMOVE ) )
{
if( !AfxGetThread()->PumpMessage() )
{
::PostQuitMessage(0);
break;
}
}
|
|
|
|
|
|
Hi
I have many sample files (of opencv) and I try to modify them so that I can get used to it. But the sample has only .c file and I need to build .cpp file to run it but I do not know how to build the .cpp file from the .c file.
Please help me.
Thank you
|
|
|
|
|
Why do you want to transform a C source file into a C++ one?
Anyway, if you simply change the file extension (to cpp ), the Visual Studio C/C++ compiler is able to differentiate.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
You're welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Use of Visual studio 2008.
|
|
|
|
|
eg.
in .idl
[id(1), helpstring("method test")] VARIANT_BOOL test([optional] VARIANT width, [optional] VARIANT height);
in .h
VARIANT_BOOL test(VARIANT width=100, VARIANT height=100);
When the parameters omit, I want them to be 100 by default.
The statement above is not right, how to write it correctly?
Thanks.
logics
|
|
|
|
|
|
My App (essentially a Cash Register App) prints during the course of a transaction to a number of Printers. AuditJournal ,Receipts , Labels, Statements. The printers may all be identical makes and models, and are connected via the USB Port. The End User may at will 're-organise' the USB Field Wiring (although hopefully not while a printjob is in progress).
The End User may also 'forget' to plug cables back in.
I need to get a DC for each printer. and I do NOT want to use:
CPrintDialog::DoModal() . The latter would give the End User's employee the chance to send the Audit Journal Print job to say, the Label Printer.
This question is not about how to print as such, have done that many a time!
Now,
-How do I create a DC to a Specified Printer without CPrintDialog::DoModal();
-How do I Differentiate between the printers.
-Is it possible to determine in advance, if say the AuditJournal Printer is actually Plugged In, Switched on, and contains Paper before a transaction Starts.
Regards
Bram van Kampen
|
|
|
|
|