|
I Have done that but is still don'r work,
And it mark this file in the top of the file.
#include "stdafx.h"
|
|
|
|
|
hie friends,
please consider following MI example.
class Base1
{
public:
virtual void func1(void)
{
}
};
class Base2
{
public:
virtual void func2(void)
{
}
};
class Derived : public Base1,public Base2
{
public:
virtual void func3(void)
{
}
};
Here C++ Books says that here derived object will contain 2 vptrs pointing to 2 vtables.My question is why two vtables instead of one?
|
|
|
|
|
In your example I don't think two vtables are needed. Generally, you need two vtables if the derived class overrides the same function in more than one baseclass:
<br />
class Base1<br />
{<br />
public<br />
virtual void func1(void);<br />
virtual void funcCommon(void);<br />
}<br />
<br />
class Base2<br />
{<br />
public<br />
virtual void func2(void);<br />
virtual void funcCommon(void);<br />
}<br />
<br />
class Derived : public Base1, public Base2<br />
{<br />
public<br />
virtual void func3(void);<br />
virtual void funcCommon(void);
}<br />
The reason for the two vtables is to make Derived act as both a Base1 and a Base2:
<br />
Base1* pB1;<br />
Base2* pB2;<br />
Derived d;<br />
pB1 = &d;<br />
pB1->funcCommon()
pB2 = &d;<br />
pB2->funcCommon()
See also the article "C+: under the hood" by Jan Gray in MSDN.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
It's quite simple to redirect console application output using unnamed pipe. The problem is that standard output stream uses buffer! Default buffer size is 4K, and output text won't be delivered until buffer is filled or program is closed.
I run application that spawns another process and should receive its output as soon as it's availible. This should be done WITHOUT smashing into child application code (so setvbuf(stdout, 0, _IOFBF, 2) or fflush()/_flushall() calls cannot be used).
So, does anyone know the way to set buffer size of another process' standard output stream?
|
|
|
|
|
Hi guys
I'm doing a Doc-View app and I want to chage the output default directory in the CFileDialog when I do an Save as..
There is a simple way to do this?
Thanks
Doc
|
|
|
|
|
set CFileDialog.m_ofn.lpstrInitialDir before calling CFileDialog::DoModal.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Thanks guy
The solution has been a little more difficult than this ( but this has to be included ) cause I needed to code CMyDOC::DoSave method to change it in my App.
Doc
|
|
|
|
|
Oh, I see! I misunderstood you question, I thought it was just about CFileDialog, not the Doc-View architechture. But you seem to have found the answer yourself, nice work.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi,
These days I'm doing a project in VB and VC++ for my second year project.
How to create the object in Win32 dll project (VC++) which will allow us to interact with my vb acivex dll "WTHCom".
method signature of activeX dll is setPath(String,String).
I want to pass two strings from Win32 dll (VC++) to VB ActiveX dll.
ActiveX dll name : WTHCom and Class name : WTHCls
Pls someone help me.
Your help is highly appreciated.
This is my AvtiveX dll code in VB
Public Function getStrings(ByVal str1 As String, ByVal str2 As String) As Integer
// Implementation of method
getStrings = 0
End Function
Thanks in advance.
Regards,
lgmperera
|
|
|
|
|
I have created a menu item in an SDI application in vc++ 6.0. the i have mapped the menu command thru class wizard and it has generated the function skelteon of the form. I can briefly tell u want I intend to do:
void CMainframe:: onclickMenu(......)
{
Get the name of the text file to be opened
Create a new window with only scrollbars;
Display the contents of the file opened in this window;
}
Please tell me how to create a window and display the text in it
|
|
|
|
|
In the window generated you can mak a RICHEdit control or even an edit control that supports multiline.
You can either do it with filemapping funtions
CreateFileMapping() //maps a file into the memory
MapViewOfFile() /*this function returns a pointer to a LPVOID which conatins the contetnt of the file*/
gabby
|
|
|
|
|
Hi,
I developed a control panel applet and placed the '.cpl' file in "C:\i soft".
I added a new key under :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Control
Panel\Cpls as ES REG_SZ C:\i soft\hvcescp.cpl
Now, this applet is displaying in the control panel and working fine,but the
icon (that I gave in resource file) is not getting displayed.
If the ".cpl" file is moved to a folder whose name does not contain space characters (e.g.: "isoft"), icon is getting displayed in control panel. Then also, applet is working when I double click on control panel item.
I am responding to the CPL_NEWINQUIRE message with the proper icon ID.
What to be done ? Is there anything wrong with Registry entry given above?
Sunil kumar.A.V., SSE.
|
|
|
|
|
sunilkumar_prog wrote:
I added a new key under :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Control
Panel\Cpls as ES REG_SZ C:\i soft\hvcescp.cpl
Since spaces are involved, have you included the path in quotation marks?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks for the reply.
We tried both single & double quotation marks.Still it is not working.
|
|
|
|
|
//Set up text color
switch(suit){
case (SUIT_CLUBS) : SetTextColor(hDC, C_BLACK); strcpy(strSuit,"Clubs"); break;
case (SUIT_DIAMONDS) : SetTextColor(hDC, C_RED); strcpy(strSuit,"Diamonds"); break;
case (SUIT_HEARTS) : SetTextColor(hDC, C_RED); strcpy(strSuit,"Hearts"); break;
case (SUIT_SPADES) : SetTextColor(hDC, C_BLACK); strcpy(strSuit,"Spades"); break;
I am a novice and would appreciate suggestions on how to fix this, The program has drop down windows i would like to change the color of the text in now it is all black. Thanks
|
|
|
|
|
Insert hDC = GetDC( hWnd ) before switch.
Be careful with strcpy function:
- no end of string
- lenght may overflow
|
|
|
|
|
I want to use command line in mfc.....but i don't know how can i fetch the
parameter of command line through mfc.......if there is any good article related to command line plz reply me.
Thanx.
keep smilling.....b'coz smile is the shortest distance between people....
|
|
|
|
|
Look for CCommandLineInfo for the MFC way in the MSDN docs ... You can also use ::GetCommandLine() Win32 API for the passed command line. Hope this helps.
- tareq
|
|
|
|
|
Thanx sir.....
keep smilling.....b'coz smile is the shortest distance between people....
|
|
|
|
|
I want use this function to view STL vector in watch window of Visual Studio debugger.
the function realisation lookes like this:
HRESULT WINAPI INT_VECTOR_TYPE_Evaluate( DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings, char *pResult, size_t max, DWORD reserved )
{
std::vector<int,std::allocator<int> > vct;
DWORDLONG qwRealAddress;
DWORD nGot;
if (pHelper->dwVersion<0x20000)
{
// Visual C++ 6.0 version
if(pHelper->ReadDebuggeeMemory( pHelper,
dwAddress,
/*what size i must pass here */
, &vct, &nGot )!=S_OK)
/* at this point we have "access violation"
return E_FAIL;
}
return 0;
}
In sample from MSDN there is structure and all workes ok.
What about vectors?
|
|
|
|
|
i am declearing a BYTE* say pDest
then i call
SafeArrayAccessData(vImage->parray , (void HUGEP**)&pDest);
my q is weather to just call
SafeArrayUnaccessData(vImage->parray);
SafeArrayDestroy(vImage->parray);
or should i also delete pDests ? by delete statements
please help me out
waiting for responce...
|
|
|
|
|
I dont think you need to delete pDest ... only SafeArrayUnaccessData and SafeArrayDestroy is sufficient. Please correct me if I am mistaking ... Hope this helps.
- tareq
|
|
|
|
|
hi frnds..
i got the code for SCREEN CAPTURE..Its working well..
now wat i need is HOW TO TRANSFER THAT CODE TO SOME OTHER MACHINE IN A LAN..
so plz frnds if u any cdoe for that send me..or if u have any suggestion plz tell me..
i will be looking forward for ur replies..
thank u
with luv
kar
Karmegakumar.A B.Tech IT
Amrita Institutions
Coimbatore
|
|
|
|
|
Look at the code below you can get the CxImage class from An article from Davide Pizzolato. Use some Transfer function to transfer the buffer to the client and decode the image and show it.
BYTE* MyIOCP::GetJPGCompressedDesktopCapture(UINT &nArraySize, int nWidth, int nHeight, BYTE nquality)
{
// get the desired window from dialog box
HWND hwnd=::GetDesktopWindow();
// get window size
CRect r;
::GetWindowRect(hwnd,&r);
int nX, nY, nX2, nY2; // coordinates of rectangle to grab
int xScrn, yScrn; // screen resolution
nArraySize=-1;
BYTE* retbuffer=NULL;
// prepare the DCs
HDC dstDC = ::GetDC(NULL);
HDC srcDC = ::GetWindowDC(hwnd); //full window (::GetDC(hwnd); = clientarea)
HDC memDC = ::CreateCompatibleDC(dstDC);
nX = r.left;
nY = r.top;
nX2 = r.right;
nY2 = r.bottom;
// get screen resolution
xScrn = GetDeviceCaps(srcDC, HORZRES);
yScrn = GetDeviceCaps(srcDC, VERTRES);
//make sure bitmap rectangle is visible
if (nX < 0)
nX = 0;
if (nY < 0)
nY = 0;
if (nX2 > xScrn)
nX2 = xScrn;
if (nY2 > yScrn)
nY2 = yScrn;
// nWidth = nX2 - nX;
// nHeight = nY2 - nY;
// create a bitmap compatible with the screen DC
HBITMAP bm =::CreateCompatibleBitmap(dstDC, nWidth, nHeight);
HBITMAP oldbm = (HBITMAP)::SelectObject(memDC,bm);
// copy the screen and resize to the bitmap
//TRACE("%i,%i",nWidth,nHeight);
// Set Correct Stretchmode
::SetStretchBltMode(memDC,HALFTONE);
::StretchBlt(memDC,0,0,nWidth,nHeight,srcDC,nX,nY,nX2,nY2,SRCCOPY);
//::BitBlt(memDC, 0, 0, nWidth, nHeight, srcDC, nX,nY , SRCCOPY);
// Create a JPG image From the bitmap..
CxImage newimage(CXIMAGE_FORMAT_JPG);
newimage.CreateFromHBITMAP(bm);
// free objects
DeleteObject(SelectObject(memDC,oldbm));
DeleteObject(memDC);
// Encode the image to the memory
CxMemFile MemFile;
//newimage.SetCodecOption(0x10,CXIMAGE_FORMAT_JPG);
// Change so that we dont have a transparent background.
newimage.SetTransIndex(-1);
// If Color change it to 24 bit bitmap.
if (!newimage.IsGrayScale())
newimage.IncreaseBpp(24);
newimage.SetJpegQuality(nquality);
MemFile.Open();
// You have to encode and decode it to compress it in reality.
// ?? Very very strange..
BOOL bRet=FALSE;
if(newimage.Encode(&MemFile,CXIMAGE_FORMAT_JPG))
{
if(MemFile.Seek(0,SEEK_SET))
bRet=newimage.Decode(&MemFile,CXIMAGE_FORMAT_JPG);
}
nArraySize=(UINT)MemFile.Size();
if(bRet)
retbuffer=MemFile.GetBuffer();
// Close & Clean up
MemFile.Close();
newimage.Destroy();
return retbuffer;
}
|
|
|
|
|
Hi. I am having problems with deleting objects from a CObArray not freeing up the memory.
NB: The code has been simplified to show only the key points.
In the header
class CBelFileDetails : public CObject
{
public:
CBelFileDetails ()
{
};
~CBelFileDetails () {};
};
In the Implementation
void RemoveArray (CObArray *pA)
{
int j, Count;
Count = pA -> GetSize ();
for (j = 0; j < Count; j++)
{
CObject* P = pA -> GetAt (j);
if (P)
{
TRY
{
delete P;
P = NULL;
}
CATCH_ALL (e)
{
e->ReportError ();
}
END_CATCH_ALL
}
}
pA -> RemoveAll ();
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
int j;
CObArray FileDetailsArray;
for (j = 0; j < NumOfFiles; j++)
{
CBelFileDetails *pFD = new CBelFileDetails ();
FileDetailsArray.Add (pFD);
}
RemoveArray (&FileDetailsArray);
}
The problem is, if I watch the 'Mem Usage' in TaskManager it forever goes up. As if the memory is not being released. I run it in debug mode, and same thing happens. But when I close the application, no memory leaks are reported.
I am wondering if any of you have encountered the same problem and if so, how did you fix it?
|
|
|
|