|
Anonymous wrote:
Is there a function which allow to see if a file with the same name already exists ?
_access() is but one method of doing that.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi guys
I have a class called CListCtrlEx and inside I want to have a pointer to a CMyDialog
Inside CMyDialog I have a CListCtrlEx member.
I tried many solutions but always receive an error message due to the cross refreneces of ine class to the other. What is the right procedure (#includes in .h or .cpp) to have a pointer of CMyDialog in CListCtrlEx.h and a CListCtrlEx member in CMydialog.h
I'm going crazy with this silly mistake.
Simplifying
In CListCtrlEx.h : CMyDialog *m_pMyDialog;
In CMyDialog.h : CListCtrlEx m_lstMyList;
Thanks
Doc
|
|
|
|
|
you can put either #include s into .cpp or .h (depends on how you create your headers also/ what are needed in your headers).
ben careful you have exclusive preprocessor directives in your header to avoid that sort of recursive definitions :
CMydialog.h
<font style="color:blue;">#if</font> !<font style="color:blue;">defined</font>(__CMYDIALOG_H_INCLUDED__)
<font style="color:blue;">#define</font> __CMYDIALOG_H_INCLUDED__
<font style="color:green;">
<font style="color:blue;">#endif</font> <font style="color:green;">//__CMYDIALOG_H_INCLUDED__</font>
TOXCCT >>> GEII power
|
|
|
|
|
I've got the following
In ListCtrlEx.h
class CMyDialog;
CMyDialog *m_pMyDialog;
In ListCtrlEx.cpp
#include "MyDialog.h"
----------
In CMyDialog.h
#include "ListCtrlEx.h"
CListCtrlEx m_lstMyList;
I always receive this error
error C2065: 'IDD_CE_GENERAL' : undeclared identifier
C:\Whatever...\MyDialog.h(25) : error C2057: expected constant expression
Do you see the problem? I can't ((
Thanks again
Doc
|
|
|
|
|
perhaps you also need an extern keyword, to tell the compiler that you use a variable in a file, but that variable is defined in another file.
what is IDD_CE_GENERAL ??
TOXCCT >>> GEII power
|
|
|
|
|
Is the general dialog IDD.
// Dialog Data
//{{AFX_DATA(CStatsGenCE)
enum { IDD = IDD_ESTAD_CE_GENERAL };
//}}AFX_DATA
|
|
|
|
|
haven't you modified some lines dangerously ?
IDD_ESTAD_CE_GENERAL != IDD_CE_GENERAL
TOXCCT >>> GEII power
|
|
|
|
|
Not at all, sorry my fault, It has only modified in the posts.
IDD_ESTAD_CE_GENERAL is the good one.
All is coherent in the code.
I'm lost (((
Thanks
Doc
|
|
|
|
|
sorry, i'm lost too...
maybe with more explanation, but nop, can't help you man
TOXCCT >>> GEII power
|
|
|
|
|
I've found it!!!
The problem is that IDD_ESTAD_CE_GENERAL value cannot be accesed by my class (I don't know why)
Maybe is not a good solution but I've substituted IDD_ESTAD_CE_GENERAL for his value and all is working correctly.
This value is always the same,isn't it?
Thanks pal for your time.
Doc
|
|
|
|
|
as you say, not a very good solution !
try to find out why this was nos accessible....
TOXCCT >>> GEII power
|
|
|
|
|
doctorpi wrote:
error C2065: 'IDD_CE_GENERAL' : undeclared identifier
C:\Whatever...\MyDialog.h(25) : error C2057: expected constant expression
IDD_CE_GENERAL will be defined in your resource.h file. Make sure that you #include "resource.h" in your include tree. You can place it in your MyDialog.h header.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
Thanks Michael
Just tried and... working
|
|
|
|
|
The best soluton when you have such cross references is to declare in one of the class a pointer to the other (like CMyDialog* m_pMyDialog in CListCtrlEx.h) and to add the following line at the top of this file:
class CMyDialog .
This will tell the compiler that the class will be declared after (in the cpp file for example). This works only for pointers because when you declare a class, the compiler needs to know the exact size of the object (for a pointer, ths size is always the same).
So, you will have to include MyDialog.h in the ListCtrlEx.cpp file.
You'll have to include also ListCtrlEx.h in the MyDialog.h header file.
Hope this is clear enough
|
|
|
|
|
the program is below: IDC_STATIC is a static control ID,i want replace the static text with a black rectangle.
void CMy06aDialog::OnPaint()
{
CWnd *pWnd=GetDlgItem(IDC_STATIC1);
CDC* pControlDC=pWnd->GetDC();
pWnd->Invalidate();
pWnd->UpdateWindow();
pControlDC->SelectStockObject(BLACK_BRUSH);
pControlDC->Rectangle(0,0,10,10);
pWnd->ReleaseDC(pControlDC);
}
but although it runs ,to my disappointed ,the black rectangle is frequently flash .how to solve this problem,what is the reason for it?
|
|
|
|
|
Your problem is the following lines with the WM_PAINT method:
pWnd->Invalidate();
pWnd->UpdateWindow();
These cause a WM_PAINT message to be sent. Therefore you are forcing a redraw within a redraw!
Removing these lines should have the desired result.
Ant.
|
|
|
|
|
yes ,you are right,i do it in your advice,thank you . ;P
|
|
|
|
|
..on a MFC Dialog Title Bar, i have tried copying from the char map and pasting doesn't work.
i can't even remember what my point is now, but anyway, i'm correct
Barring unforeseen acts of God and Adminstrators, my server will be up tomorrow. I'm more worried about the Adminstrators.
|
|
|
|
|
you must be sure you are unicode-working.
TOXCCT >>> GEII power
|
|
|
|
|
I think you need to select the appropriate font as well ???
just a guess(if no one could give you the exact ans).
|
|
|
|
|
Hello,
at the moment I'm working on a DLL (swlib.dll) at my company and I use the code very often at home. The problem is that the project paths are different:
The application called Renamer3 is in the path
f:\vc++\renamer3 <- at home
f:\programmieren\_code\renamer3 <- at work
so I had the ideo to configure the output path of the dll in the stdafx.h to prevent editing the project settings every day.
I put this code to the stdafx.h
#define HOME // --> when I'm not at home this line will be commented
#ifdef HOME
#define __SW_LIB_OUTPATH "\"f:\\vc++\\Renamer3\\"
#else
#define __SW_LIB_OUTPATH "\"f:\\programmieren\\_code\\Renamer3\\"
#endif
#ifdef _DEBUG
#define __SW_LIB_CONFIG "Debug\\"
#else
#define __SW_LIB_CONFIG "Release\\"
#endif
#pragma comment(linker, "/out:" __SW_LIB_OUTPATH __SW_LIB_CONFIG "SWLib.dll\"")
#pragma comment(linker, "/implib:" __SW_LIB_OUTPATH __SW_LIB_CONFIG "SWLib.lib\"")
#pragma comment(linker, "/pdb:" __SW_LIB_OUTPATH __SW_LIB_CONFIG "SWLib.pdb\"")
Well, but now I'm flooded by 49 Linker warnings and 1 Linker error (when I'm only trying to compile the DLL, not the Renamer3 which depends on it):
warning LNK4070: The directive /OUT:f:\vc++\Renamer3\Debug\SWLib.dll in .EXP does not match the output filename "f:\vc++\Renamer3\debug/SWLib.dll"; directive will be ignored
and
fatal error LNK1104: File "f:\vc++\Renamer3\Debug\SWLib.lib" can't be opened
(I tried to translate the linker messages to English because I'm from Germany, so they could defer from the correct messages )
What's wrong with this code? I think it might be correct...What's strange too is that the fatal error only appeared when I deleted the SWLib.lib in the Folder f:\vc++\renamer3\debug. Before that I was able to compile the Renamer3 but at startup I got a windows message box telling "The application or DLL "f:\vc++\Renamer3\Debug\SWLib.dll" is no valid Windows-File. Check this with the installation disk" ???
I really have no idea what this should mean, the dll ist definitely working!
|
|
|
|
|
I had the same issues, different paths to the project directory on different machines. The solution is used was to add the project directory to the list of include directories and then use #include <> notation.
e.g. (using VC6)
On home machine add 'f:\vc++' to list of include directories in Tools-Options-Directories-Include
On work machine add 'f:\programmieren\_code' to ...
Then in all your code use
#include <Renamer3\...> type sytax.
There shouldn't be any need to mess with the Debug/Release directories.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
great, that's the solution and it's fairly easy! i had another approach -> i used different configurations but that's more complicated...
thank you very much!
|
|
|
|
|
Glad to help.
It's also worth looking at the other directories to set as well i.e. executable, library and source.
For all directory settings make sure the order of the paths is correct, usually yours should be last.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
right, i forgot something: how can i say my main application (the exe) the path of the dll? when i build the program the dll will be placed in
f:\vc++\swlib\debug
and the exe is in
f:\vc++\renamer3\debug
the very issue is that i have more than one program which depend on the dll and the dll isn't complete so i edit one program and the dll, build it and everytime i changed the program i had to change the ouput folder of the dll as well...very annoying
|
|
|
|