|
'm_hBit' is an object to CBitmap Class. CDC::SelectObject() accepts pointer to CBitmap. You can have an CBItmap object in two steps,
CBitmap m_hBit;
m_hBit.LoadBitmap(...); //you can use other initializtion methods too
After these two steps, you can use m_hBit object in CDC::SelectObject()
|
|
|
|
|
hi all,
how much heap memory allocated for a process?
how much stack memory allocated for a process?
if i have 512MB RAM and trying allocate 1GB of Heap memory what will happen??
please explain or give me links.
Thanks in advance.
|
|
|
|
|
Default heap size is 1mb,this can be changed using the /heap linker option.An application can directly use about 2gb
of address space.
Same for stack also,1mb is the default and can be changed using the /stack linker option
|
|
|
|
|
but what will happen , if i have 512MB RAM and trying to allocate 1GB of heap memory?
please give me the links or suggest any books?
thank u.
|
|
|
|
|
It will attempt to allocate the memory from virtual memory
Darka [Xanya]
|
|
|
|
|
BTW, 2GB is for 32-bit Windows, which is the total limit of stack plus heap plus none-user memory.
Best,
Jun
|
|
|
|
|
I m using _wrename( ) in my VC code.. when i register file in the file system and rename them using _wrename() after performing this many times, the new files are registered correctly and renamed appropriately but somehow the files registered earlier gets deleted from the file system. now each time the new file is registered an d renamed an old file is deleted.. I m unable to track the reason behind this..
Please help me with an appropriate logic behind this..
Thanks in advance..
|
|
|
|
|
what u r mentioning as old and new file. say their is a file '1.txt' and '2.txt',now rename '1.txt' to 'a.txt', whtz happening? is '2.txt' get deleted now?
|
|
|
|
|
Parthi_appu wrote: what u r mentioning as old and new file. say their is a file '1.txt' and '2.txt',now rename '1.txt' to 'a.txt', whtz happening? is '2.txt' get deleted now?
Yes after registering and renamingmany files say 1.pdf,2.pdf,.....200.pdf, now when 201.pdf is registered and renamed some previous file like 10.pdf gets deleted and on subsequent renaming of more files, 11.pdf, 12.pdf and so on gets deleted.
|
|
|
|
|
Hi all,
Can any one plz tell me how to set the hook in MFC.
Thanks in advance.
|
|
|
|
|
Seting the hook using :-
SetWindowsHook
removing the hook:-
UnhookWindowsHook
MSDN and codeproject are having nice article on hooking.
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
|
|
|
can anyone send some simple examples showing the WM_TIMER implementation?
|
|
|
|
|
|
|
Hi,
Try the below sample,
void CMainFrame::OnStartTimer() <br />
{<br />
m_nTimer = SetTimer(1, 2000, 0);<br />
}<br />
<br />
void CMainFrame::OnStopTimer() <br />
{<br />
KillTimer(m_nTimer); <br />
}<br />
<br />
void CMainFrame::OnTimer(UINT nIDEvent) <br />
{<br />
AfxMessageBox("Timer"); <br />
CFrameWnd::OnTimer(nIDEvent);<br />
}
|
|
|
|
|
See example in msdn Here[^]
whitesky
|
|
|
|
|
Thanks for that.
For my application, can I use the following
Is this correct way of doing?
On_send(wparam,lparam)
{
//packet sent to serial device
//timer has to be triggered on here
SetTimer();
}
On_rx(wparam,lparam)
{
//checks for packet received
//if no packet received from serial device, then
{
//check for timer has elapsed
OnTimer()
{
//resend the packet to MPU
post_message(WM_RESEND,null)
}
}
}
On_resend(wparam,lparam)
{
//send same packet to PC
here, I have to restart the timer again to see if the
serial device responded within particular time as in On_rx.
KillTimer();
SetTimer();
}
What more do I need to add?
|
|
|
|
|
timer will call itself, you don't need to call that function!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Created a class i.e. CFlipCustomViewer derived from COleConrol class(abstact class)and
overridden the "virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)" method of COleControl class in the void CFlipCustomViewer::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid).I tried to call this in OnInitDialog() method of my dialog class of the application.Here the code snippets..
BOOL CFlip::OnInitDialog()
{
//having a CStatic as a place holder and then
//create the flip custom control in InitDialog
COleControl* ptrOleControl; //abstract base class pointer
CFlipCustomViewer* ptrFlipCustomViewer; //derived class pointer
ptrOleControl = ptrFlipCustomViewer; //derived class pointer assigned to abstract base class pointer
ptrOleControl = new CFlipCustomViewer(); //error in this instantiation of derived one
CDC* pdc = GetDC(); //get the device context
CRect rcBounds;
CRect rcInvalid;
GetClientRect( &rcBounds);
GetClientRect( &rcInvalid);
ptrOleControl->OnDraw(pdc,rcBounds,rcInvalid);//place holder for flipping action
CDialog::OnInitDialog();
return TRUE;
}
****************************************************************************************
but while compiling i am getting the following errors as below :
error C2259: 'CFlipCustomViewer' : cannot instantiate abstract class due to following members:
d:\fancyviewer\flipsample\flipcustomviewer.h(14) : see declaration of 'CFlipCustomViewer'
d:\fancyviewer\flipsample\flip.cpp(200) : warning C4259: 'long __thiscall COleControl::GetClassID(struct _GUID *)' : pure virtual function was not defined
d:\program files\microsoft visual studio\vc98\mfc\include\afxctl.h(683) : see declaration of 'GetClassID'
d:\fancyviewer\flipsample\flip.cpp(200) : warning C4259: 'unsigned int __thiscall COleControl::GetUserTypeNameID(void)' : pure virtual function was not defined
d:\program files\microsoft visual studio\vc98\mfc\include\afxctl.h(936) : see declaration of 'GetUserTypeNameID'
d:\fancyviewer\flipsample\flip.cpp(200) : warning C4259: 'unsigned long __thiscall COleControl::GetMiscStatus(void)' : pure virtual function was not defined
d:\program files\microsoft visual studio\vc98\mfc\include\afxctl.h(937) : see declaration of 'GetMiscStatus'
d:\fancyviewer\flipsample\flip.cpp(200) : error C2259: 'CFlipCustomViewer' : cannot instantiate abstract class due to following members:
d:\fancyviewer\flipsample\flipcustomviewer.h(14) : see declaration of 'CFlipCustomViewer'
****************************************************************************************
Can anyone helpme out please ?
|
|
|
|
|
You need to override all the pure virtual functions of an abstract base class, but why not just derive from from CWnd instead?
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hello everyone!
Look at my code:
int Interface::InitScreen()<br />
{<br />
ifstream mainUIScreen((string(".\\") + string(DIR_SCREENS) + string("mainui.asc")).c_str());<br />
ofstream mainUIScreen_Edit((string(".\\") + string(DIR_SCREENS) + string("mainui_edited.asc")).c_str());<br />
<br />
if (!mainUIScreen.is_open())<br />
{<br />
MessageBox(NULL, "Cannot open program file 'mainui.asc'!", "Error",<br />
MB_OK | MB_ICONEXCLAMATION);<br />
exit(-1);<br />
}<br />
<br />
if (!mainUIScreen.good())<br />
{<br />
MessageBox(NULL, "Cannot open program file 'mainui.asc'!", "Error",<br />
MB_OK | MB_ICONEXCLAMATION);<br />
exit(-1);<br />
}<br />
<br />
char c;<br />
for (int x = 0; x < WIDTH*HEIGHT; x++)<br />
{<br />
c = mainUIScreen.peek();<br />
mainUIScreen_Edit.put(c);<br />
}
When I open the output file (mainui_edited.asc ), I get a bunch of 0x98 's instead of the chars I want... Why is that? Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
To anyone that reads this: I was using an Unicode file...
Windows Calculator told me I will die at 28.
|
|
|
|