|
Hi,
I am new to programing . I often come across the word "Wrapper class" in some books. What is it?.
What is a type library? When I open a *.tlb, I see a whole chunk of hexadecimal display.
Thanks.
Deepak Samuel
|
|
|
|
|
wraper class as a short example.
win32 programming
HWND hWnd;
hWnd = createwindow(...);
ShowWindow(hWnd,...);
Wrapper to window (HWND)
class Window
{
HWND hWnd;
int CreateWindow(...)
{
hWnd = CreateWindow(....);
}
int ShowWindow(...)
{
ShowWindow(hWnd,...);
}
}
As you see i wrapped HWND with a class, hence its a wrapper class.
|
|
|
|
|
As for tlb files you can view them with the Visual C++ tool OLE/COM object viewer
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Deepak Samuel wrote:
What is a type library? When I open a *.tlb, I see a whole chunk of hexadecimal display.
A .tlb is used to describe the methods and properties of a COM object.
You can use #import to create a C++ wrapper class for the type library or you can view the details of the type library using the OLEView too that comes with Visual Studio.
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
|
|
|
|
|
I use this :
CFile FileName(m_csTemp,CFile::modeCreate | CFile::modeWrite);
to create a file. This expression erase all of the existing files which have the same name. Is there a function which allow to see if a file with the same name already exists ?
Thank's for advance.
|
|
|
|
|
|
Try to open it for read, if it fails means it doesnt exist
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
use
BOOL PathFileExists(LPCTSTR pszPath);
or to open without deleting
if(!file.Open(strFileName,CFile::modeReadWrite|CFile::modeCreate|CFile::modeNoTruncate,&exF))
return 0;
suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
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
|
|
|
|