|
When I add this to my stdafx.h:
#pragma once
#ifndef foo
#define foo
#pragma message( "************i should be seen once*****************" )
#elif
#pragma message( "************i should be seen a lot*****************" )
#end#pragma once
#ifndef foo
#define foo
#pragma message( "************i should be seen once*****************" )
#elif
#pragma message( "************i should be seen a lot*****************" )
#endif
if
all I see in the compiler is the first message? Shouldn't it print the top message once, then lots of copies of the second message?
What obvious mistake am I making /this/ time?
TIA,
Pete
|
|
|
|
|
sorry, that code should have read as follows:
#pragma once
#ifndef foo
#define foo
#pragma message( "************i should be seen once*****************" )
#elif
#pragma message( "************i should be seen a lot*****************" )
#endif
|
|
|
|
|
No, because stdafx.h is preprocessed only once. See the VC forum FAQ, I have a FAQ on how precompiled headers work.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Good Eyes
I first looked at that question and I could not see why it would be failing, then I see your response and realized he was doing it in the precompiled header.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Ok, I've just read the FAQ (thanks for that btw), but I'm still confused.
I selected "Not using pch" in the project settings, and created a new header file which contains the following:
#include "stdafx.h"
#include <streams.h>
#include <initguid.h>
#include <qedit.h>
#pragma once
#ifndef foo
#define foo
#pragma message( "************i should be seen once*****************" )
#elif
#pragma message( "************i should be seen a lot*****************" )
#endif
this file is <bold>#include'd by a few other headers.
But I'm still only seeing the first line
By my reasoning, the header should be (pre)processed at least twice, since I see the first line a few times. So what's going on? are the defines not persistent throughout the preprocessing?
I'm confused!
Thanks for any input,
Pete
|
|
|
|
|
I want to create a simple application that exists only as a dialog. Thats easy enough. But I want that dialog to be a tabbed dialog.
That seems like it should also be easy but I'm stuck. Does anyone have a hint on this should be done?
Ron
|
|
|
|
|
If ur using MFC, check out CPropertySheet and CPropertyPage ,
otherwise have a look at the PropertySheet and CreatePropertySheetPage function.
Cheers!
Marc
|
|
|
|
|
I should have indicated I knew how to use the property sheet but my problem is getting the property sheet into the dialog that you get when you create a dialog based application.
I can create a property sheet dialog on the fly but then my application shows that dialog, and when I dismiss it, the application dialog pops up. I want them to be one and the same.
Ron
|
|
|
|
|
Ron,
Create a modeless property sheet as a child of your dialog, and do this in the dialog's OnInitDialog() handler. I often use an invisible frame in my dialog's resource to position and size the property sheet. This lets me easily add other controls to the dialog, since I can see the exact location of the property sheet in the resource editor.
/ravi
Let's try putting "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
|
I think you should try to either:
- A: Change the base class of your CMyAppDlg from CDialog to CPropertySheet
- B: Check out this thread about how to make a CPropertySheet the child window of your dialog.
Cheers!
Marc
|
|
|
|
|
Look for some code that does the equivalent of FindFirstFile/FindNextFile for linux/unix.
OK I know this is not a VC++ question per se, but bear with me
If any of you who are out there and are familiar with unix/linux know this, any help would be appreciated !
|
|
|
|
|
Wohoo! First Linux question.
look at opendir, readdir and closedir
|
|
|
|
|
Wohoo! First Linux question.
Ha! I'm actually even replying from within linux using Konqueror !
look at opendir, readdir and closedir
OK you wouldn't happen to have any sample code lying around ?
The code is for porting the Visual Component Framework to linux. And this stuff specifically is to use in allowing file searches
Thanks !
|
|
|
|
|
Jim Crafton wrote:
OK you wouldn't happen to have any sample code lying around ?
The following sample code searches the current directory for the entry name.
dirp = opendir(".");
while (dirp) {
errno = 0;
if ((dp = readdir(dirp)) != NULL) {
if (strcmp(dp->d_name, name) == 0) {
closedir(dirp);
return FOUND;
}
} else {
if (errno == 0) {
closedir(dirp);
return NOT_FOUND;
}
closedir(dirp);
return READ_ERROR;
}
}
return OPEN_ERROR;
This is directly from readdir() documentation.
|
|
|
|
|
I want to get the text that just selected before activating(restore from sys tray) my application. For example; when I select any text in IE and restore my aplication. How can I do this
kozlu
|
|
|
|
|
If I'm understanding correctly, select the text in IE and use the Edit->Copy menu function to save it to the clipboard. Then, in your application, read from the clipboard into a buffer and have your way with it.
|
|
|
|
|
How are null values in database fields dealt with in C++ ADO #import msado15.dll.
I can retrieve data and display it if there are no nulls in the data.
The sql stops displaying at a null and will not display anything after it.
(It's as if the null acts as a string terminator )
Part of script...
while(!pRecordset->GetEndOfFile()){
for(int loop=0;loop<precordset->Fields->Count;loop++)
{printf("Name is '%s'\n",
(char*) ((_bstr_t) pRecordset->GetFields()->GetItem((short)loop)->GetName()));
printf("Value is '%s'\n",
(char*) ((_bstr_t) pRecordset->GetFields()->GetItem((short)loop)->GetValue()));
}
}
Any help here would be great!
|
|
|
|
|
GetValue (from FieldPtr) returns a _variant_t reference which basically just wraps a VARIANT. The case you are performing here is not safe because the VARIANT can be set to type VT_NULL or VT_EMPTY which cannot be cast to char*. To do this corretly, you need to check the type of GetValue (ie. VT_NULL or VT_EMPTY indicates a NULL value.)
|
|
|
|
|
Can you point me in the right direction for the use of VT_NULL or VT_EMPTY in an example or two...?
Searching the net I cannot see the wood for the trees at the moment!
Thanks
|
|
|
|
|
_variant_t varValue = pRecordset->GetFields()->GetItem((short)loop)->GetValue();
if (varValue.vt == VT_NULL || varValue.vt == VT_EMPTY)
{
printf("NULL");
}
else
{
printf((char*)(_bstr_t)varValue);
}
|
|
|
|
|
Hi there:
I am willing to learn how to write a custom pure API control (something simple for a start: e.g. equivalent of CStatic).
Could you give me an idea where to start or where to get more information on these kind of things?
Thank you.
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|
|
You will need to look at RegisterClass in order to create a window class that can be used to create your window. CreateWindow in order to create an instance of your custom class. Windows procedures in order to apply the functionality that you need.
If you would like to build your custom control on top of an existing windows control, you could also look up window subclassing.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
What I am looking for is to avoid using MFC completely.
Can you be a little bit more elaborate, or even better, refer me to a specific example? Thanks.
A reasonable man adapts himself to the world. An unreasonable one persists, trying to adapt the world to himself. That is why all the progress in the world depends on the unreasonable men.
|
|
|
|
|
All of those functions that I mentioned previously are from the Win32 API. So you will not need to use MFC with those functions.
Creating a custom control is not much different than creating an application window for a raw Win32 application. One of the only differences is when you create your control, you create it as a child of another window.
Try creating a new Win32 Windows Application project in VC++. It will generate a set of basic code to create the application window. It shows how to use the functions that I mentioned, RegisterClass, CreateWindow, and the WindowProc.
You should be able to adapt the window class that they create into the control that you would like to create. Simply modify the styles, and add the functionality that you would like to provide in the WindowProc procedure to handle the windows messages the way that you want.
I am sorry that I do not have a more concrete example on hand.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|