|
I basically have
foo.h
#include "bar.h"
bar.h
#include "foo.h"
and it results in fatal error C1014: too many include files : depth = 1024.
So I tried doing '#pragma once' in each file, no luck. I then tried doing
#idndef UNIQUE_IDENTIFIER
#define UNIQUE_IDENTIFIER
// all header code
#endif
That didn't work so I tried using the pragma once statement & the above with no luck.
When I say the previous solutions 'didn't work' I mean that objects from foo.h could not be recognized by methods that required them in bar.h, the compiler didn't know what they were.
Ideas?
Thanks!
|
|
|
|
|
chasetoys wrote: ...objects from foo.h could not be recognized...in bar.h
You might need to use either a pointer or a forward declaration.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Could you please elaborate? I'm kind of a newbie
|
|
|
|
|
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
I don't know if my comments will help, or add anything to DavidCrow's reference, but here it is anyway.
In my include files I am able to control their contents. I don't know if you can define the contents of "foo.h" and "bar.h", but if you can try the following:
foo.h
struct Foo_Struct {
// Bar_Struct* bar; // wrong, Bar_Struct is not known yet
struct Bar_Struct* bar; // correct, compiler knows Bar_Struct is a struct
};
bar.h
struct Bar_Struct {
// Foo_Struct* foo; // wrong, Foo_Struct is not known yet
struct Foo_Struct* foo; // correct, compiler knows Foo_Struct is a struct
};
This will work as long as the type is known but it is not used. If you tried "struct Bar_Struct bar" instead of "struct Bar_Struct* bar" it would not work unless struct Bar_Struct is fully known at the time ("bar.h" would have to be included first). You can have one of the files declare one of the structs (by correctly selecting the inclusion order), but there is no easy way to have both if none of them is a pointer. The same applies to classes, obviously.
Rilhas
|
|
|
|
|
Hi, I have a dialog application that I would like to have on top of another application at all times.
I have tried using CWnd::SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE), but that will keep my app on top of all windows, not just the single application I'm aiming for.
It looks as though I will need to get the pointer to the CWnd for the other app and use that as the first arg to SetWindowPos() to get the results I want.
So far, I have retrieved the process ID for the other application, but I don't know how to retrieve the CWnd * given that ID.
Is there a better approach than using CWnd::SetWindowPos()?
I am using vc++ 6.0.
Any help is appreciated.
Thanks!
|
|
|
|
|
pince wrote: So far, I have retrieved the process ID for the other application, but I don't know how to retrieve the CWnd * given that ID.
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Thanks for the reply. I included the code from the link you gave me and tried to create a CMainWindowIterator. However, the compiler complains b/c it doesn't recognize the EnumProcesses and EnumProcessModules functions from his code. MSDN lists these other the "psapi.h" header, so I tried including <psapi> and <psapi.h>, but the compiler for 6.0 didn't recognize these either. These appear to be .NET dlls? How can I use this for 6.0?
Thanks.
-- modified at 15:02 Thursday 27th April, 2006
|
|
|
|
|
pince wrote: These appear to be .NET dlls?
No. They work fine with v6, but you'll need the Platform SDK first.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
I got a hold of the psapi files, and everything compiles fine in Debug mode. Except the window doesn't stay on top of the other app (it behaves as any other window). Here's my code:
DWORD appPID; // the pid of the application I want my app to stay on top of
CMainWindowIterator wndIter(appPID);
HWND appHwnd = wndIter.First();
CWnd * pAppCWnd = FromHandle(appHwnd);
SetWindowPos(pAppCWnd , 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Also, when I build in release mode, I get the following warning:
LINK : warning LNK4089: all references to "PSAPI.DLL" discarded by /OPT:REF
|
|
|
|
|
Hi there,
I wish to make my edit control accept only capital letters in combination with numbers. The member variable (m_confirmation_num) for that control is a CString with max characters of 5. That string later gets converted to a UINT conf_num. Initially m_confirmation is set to NULL and m_conf_num to 0. The edit control is defaulted to "00000" when the dialog box is first opened. With CAPS LOCK on or OFF, the edit control accepts only capital letters. This is what I want but why does it do that. This only happens with the following set up but for cases where I do not want the zeroes to display in the field, it accepts lowercase.
Is there a way to make the edit control accept only capital letters? Or have the lowercase changed to uppercase upon user input? And is there a function that checks to see if a char is uppper or lowercase? Thanks.
|
|
|
|
|
see in the edit box properties in design editor...
|
|
|
|
|
Duh. I've looked at the properties but somehow overlooked it. Thanks a lot!
|
|
|
|
|
One solution is WM_CHAR message.
Kuphryn
|
|
|
|
|
|
I suppose it could just be that the line.length is reporting the length of the line with a newline and carriage return character stripped out, but the tellg is "telling it like it is"
|
|
|
|
|
ldsdbomber wrote: I suspect this is something to do with each line having a newline/carriage...
Put the call to tellg() in the for loop to know for sure.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
I have been scouring the web, msdn, and the help files trying to figure out how to do this, and have gotten nowhere except a web of abstract articles on Active Directories, and I'm not really sure A.D. is what I need to use to do this.
Can someone please point me in the right direction?
Thanks in advance for any help you can give.
-Mike the Red
Extra Details, just in case they're relevant:
I'm using DAO to access a database on another computer on the network, which fails if the local machine does not already have an open connection to the server computer. I'm looking to check for the connection before opening the DAO object, and create the connection if it's not connected.
I have serviceable, though not pretty, methods for checking the connection, but have no idea how to create it.)
|
|
|
|
|
Mike the Red wrote: I'm using DAO to access a database on another computer...
What does this code snippet look like?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
To simplify the process, this is the code snippet to open a DB that uses the default system database (usr/pass db).
#include <afxdao.h>
CDaoDatabase* daoDB = new CDaoDatabase();
try {
daoDB->Open("\\\\Main\\E-Drive\\DB\\Operational.mdb", false, true);
} catch (CDaoException * daoE) {
return false;
} catch (Exception* e) {
return false;
};
if (!daoDB->IsOpen()) {
return false;
};
Thanks again,
Mike the Red
|
|
|
|
|
So what exception is thrown, or what error do you receive?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
The daoDB->ReportError() method reports:
The Microsoft Jet database engine cannot open the file '\\Main\E-Drive\DB\Operational.mdb'.
It is already opened exclusively by another user, or you need permission to view its data. If, however, I open My Computer and type '\\Main\E-Drive\DB\' (or any valid path on \\Main) in the address bar, it prompts me to enter my user/pass, and then displays the contents of the drive/folder.
After doing that, if I run the program again, I will no longer receive the error message and the DAO engine can access the file without issue.
(It also works if I map a network drive to some share on \\Main .)
My problem is that I can't seem to find a way to programatically connect to \\Main so that the share can be accessed.
-MZR
|
|
|
|
|
Would is be acceptable to call NetUseAdd() first to map a drive letter to \\Main\\E-Drive, and then use that drive letter in the call to Open() ?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
I don't know how none of my searches turned that up, but thank you. I pulled up NetUseAdd in the help file, and the first thing (ok, second thing) it says is that you don't have to actually map the drive - you can use it to just authenticate with the server for future transactions. This should be perfect!
Thanks, Mr. Crow - what a great help!
|
|
|
|
|
Hello,
I am using an user defined List Control in my application. (CXListCtrl provided by Mr. Hans in Code Project).
If any other window (whose size is less than the size of Control size) is placed and removed that area is not repainted. When I checked OnPaint () of the implemeentation of control is left for default by calling Default () function. I tried to replace Invalidate () before that but it goes for indefinite loop as Invalidate () also invokes OnDraw function.
I tested by invoking a notepad making the size of it less than the size of List control, place it on top the control and switch back to my application. I find the area of notepad being blank. Placing some TRACE Message I found that OnDraw () function of the control is called when i do that test. But since Default () function is called it is not painting that area.
Can any one suggest me what can be done to avoid the repainting problem?
I am developing an MFC SDI application in .NET environment on Windows XP.
Thanks for your Time
Ravi
|
|
|
|