|
The interface thread must receive the message. Then pass it along to your other threads using semaphores/conditions/queues, or whatever you use for intrathread communications.
--
Booohoo!
|
|
|
|
|
Hi
Well i am drawing on my clientDc and then i am writing to MemDC.
This MemDc i am using for saving clientDc content to Image file.
<br />
<br />
Class MyView<br />
{<br />
CDC MemDC;<br />
CBitmap m_MyBitmap;<br />
};<br />
<br />
Class MyView:rawDiag()<br />
{<br />
CClientDC dc(this);<br />
<br />
---------------<br />
Drawing code goes here. With default mapping mode <br />
---------------<br />
<br />
<br />
m_MyBmp.DeleteObject ();<br />
MemDC.CreateCompatibleDC (&ClientDC);<br />
m_MyBmp.CreateCompatibleBitmap (&ClientDC, 860, 1100);<br />
CBitmap *OldBitmap = MemDC.SelectObject (&m_MyBmp);<br />
MemDC.PatBlt (0,0,860,1100,WHITENESS);<br />
<br />
if(MemDC.StretchBlt(50, 0, 860, 1100, &ClientDC, 0, 0, 860,<br />
1100, SRCCOPY) == FALSE)<br />
AfxMessageBox("Failed to draw WFR diagram"); <br />
<br />
MemDC.SelectObject (OldBitmap);<br />
ClientDC.SetMapMode(MM_LOENGLISH);<br />
}<br />
<br />
Function for saving dc to Bitmap file. This code i got from codeproject post<br />
<br />
Class MyView::SaveDCtoBMP()<br />
{<br />
CString Filename;<br />
CFileDialog dlgFile (false,"*.*",NULL, OFN_HIDEREADONLY,"BMP Files: (*.bmp)|*.bmp||");<br />
dlgFile.m_ofn.lpstrTitle = "Save As Image File";<br />
<br />
int ret = dlgFile.DoModal(); <br />
if(IDOK == ret)<br />
{<br />
Filename = dlgFile.GetFileName (); <br />
CClientDC clientDC(::AfxGetMainWnd());<br />
clientDC.SetMapMode (MM_LOENGLISH);<br />
<br />
CBitmap TmpBitmap;<br />
TmpBitmap.CreateCompatibleBitmap(&clientDC, 860, 1100);<br />
CDC& ncDC = const_cast<CDC&>(MemDC);<br />
ncDC.SelectObject(TmpBitmap);<br />
ncDC.SetMapMode (MM_LOENGLISH);<br />
<br />
CDIBSectionLite dib;<br />
HBITMAP hnd = (HBITMAP)m_WfrBmp.GetSafeHandle (); <br />
dib.SetBitmap (hnd);<br />
dib.Save(Filename); <br />
ncDC.SelectObject(m_WfrBmp); <br />
TmpBitmap.DeleteObject ();<br />
}<br />
}<br />
<br />
I get following image as bitmap file.
I want only the clientdc content but it seems that it provides screen capture
How to attach image file alongwith post?
Leave your mark wherever you go
|
|
|
|
|
Is there any solution for this problem?
why i am getting complete mainframe window while i am using teh clientDC
I had even tried with ClientDc clientDC(this) still then.?
Leave your mark wherever you go
|
|
|
|
|
How about to use GetDCEx where you can be more specific in getting your DC.
And by the way, why is it that your bitmap size is hard-coded (below)?
Why not to use CWnd::GetClientRect(...) instead to get the size?
CBitmap TmpBitmap;
TmpBitmap.CreateCompatibleBitmap(&clientDC, 860, 1100);
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Waht are you trying to do.. Are u calling the save bitmap. actually it seems to get the main window and draws the client area.. Tell me ur requirement.
Han
|
|
|
|
|
Please follow the following link for better idea
http://www.codeguru.com/forum/showthread.php?s=d09323bd39f2dd0a942e34fe1155af42&threadid=296795
My main aim is to draw the content to view such that when user wants he can save the same to image file. Thats it?
What i tried that i drawn completely into the ClientDc and at the end (see first post) i am making the memory device context and then storing teh content to the image file.
Well but it seems that MemDC is taking the complete Mainwindow instead of the required clientdc.
Help me in this regard
Thanks in advance
sandeep
Leave your mark wherever you go
|
|
|
|
|
Hi i am trying to use ole Ipicture interface to load pictures of different formats but the OleloadPicturePath method fails.
What i am doing is given below.
any help would be appreciated and a lot of thanks in advance.
void * CMap::OpenGraphics(char * name)
{
IPicture *Ipic = NULL;
SIZE metric,pixel;
const int H_METRIC_PER_INCH = 2540;
HDC hdcScreen =GetDC(NULL);
HRESULT hr;
int SxpixPerInc = GetDeviceCaps(hdcScreen,LOGPIXELSX);
int SypixPerInc = GetDeviceCaps(hdcScreen,LOGPIXELSX);
unsigned short OlePathName[512];
ReleaseDC(NULL,hdcScreen);
mbstowcs(OlePathName,name,23);
char s[10];
MessageBox(NULL,itoa(int(OlePathName),s,10),"OLE",MB_OK);
hr = OleLoadPicturePath(OlePathName,NULL,0,0,IID_IPicture,(void **)(Ipic));
if(hr)
{
MessageBox(NULL,"ERROR WHILE LOADING PIC PATH","",MB_OK);
return 0;
}
if(Ipic)
{
Ipic->get_Height(&metric.cy);
Ipic->get_Width(&metric.cx);
pixel.cx = (SxpixPerInc*metric.cx + H_METRIC_PER_INCH/2)/H_METRIC_PER_INCH;
pixel.cy = (SypixPerInc*metric.cy + H_METRIC_PER_INCH/2)/H_METRIC_PER_INCH;
ImageInfo.Ipic = Ipic;
ImageInfo.pixel = pixel;
ImageInfo.metric=metric;
ImageInfo.path = name;
return Ipic;
}
return 0;
}
|
|
|
|
|
Hi there,
You are missing an & in front of Ipic.
hr = OleLoadPicturePath(OlePathName,NULL,0,0,IID_IPicture,(void **)(<big>&</big>Ipic));
Fabian
|
|
|
|
|
Hello everyone.
I want to attach a dialog to display as a view. How to do it?
Please help me.
Thank you.
-Freehawk
|
|
|
|
|
do you mean of FormView
Leave your mark wherever you go
|
|
|
|
|
Just use CFormView class.
|
|
|
|
|
Dear Friends,
Suppose i got an ActiveX control (or any COM dll). I am distributing it will by application. Now the problem is that anyone can utilize that dll or OCX. I want to prevent others to use my OCX and dlls. How can i ensure the security of my COM controls so that no one else can use it.
Imtiaz
|
|
|
|
|
HI One Idea is...
Create Time:
in OCX or DLL define a variable with some value let XXXX
& check at load time. if false then exit.
On Use time:
at contructor or on_load set that value as XXXX(as u set that in coding u know that..) & then start application....
OK! Bye
---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
MapViewOfFile() if giving me an address that is out of process address range. Trying to use it gives me an access violation as expected. All parameters passed in to MapViewOfFile seems to be fine. Anyone has faced the same problem before ?
Thanks
|
|
|
|
|
(From MSDN)
Reading from or writing to a file view can cause an exception. For example, accessing a mapped file that resides on a remote server can generate an exception if the connection to the server is lost. Exceptions can also occur because of a full disk, because the file is shared and a different process has locked a byte range, or because of an underlying device failure or memory allocation failure. To guard against exceptions due to input and output (I/O) errors, all attempts to access memory mapped files should be wrapped in structured exception handlers.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Check the last parameter to CreateFileMapping as I think this needs to be a wide character string otherwise you get a GPF then or later.
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
Now I want set the Paragraph JUSTIFY alignment of text like Microsoft word.Paragraphs are justified at the two sides of the text;
I do this by follow,but it is of no effect,I don't know
what it's the reason.Can you help me?
_AFX_RICHEDITEX_STATE _afxRichEditStateEx ;
_AFX_RICHEDITEX_STATE::_AFX_RICHEDITEX_STATE()
{
m_hInstRichEdit20 = NULL ;
}
_AFX_RICHEDITEX_STATE::~_AFX_RICHEDITEX_STATE()
{
if( m_hInstRichEdit20 != NULL )
{
::FreeLibrary( m_hInstRichEdit20 ) ;
}
}
//AfxInitRichEditEx by called in the InitInstance() function of the App.
BOOL PASCAL AfxInitRichEditEx()
{
if( ! ::AfxInitRichEdit() )
{
return FALSE ;
}
_AFX_RICHEDITEX_STATE* l_pState = &_afxRichEditStateEx ;
if( l_pState->m_hInstRichEdit20 == NULL )
{
l_pState->m_hInstRichEdit20 = LoadLibraryA( "RICHED20.DLL" ) ;
}
return l_pState->m_hInstRichEdit20 != NULL ;
}
void CAutoRichEditCtrl::SetParagraphJustify()
{
PARAFORMAT2 pf;
pf.cbSize = sizeof(PARAFORMAT2);
pf.dwMask = PFM_ALIGNMENT;
pf.wAlignment = PFA_JUSTIFY;
SetParaFormat(pf);
}
|
|
|
|
|
Hi
I have one quick question here: is it possible to insert a class with private copy constructor and assignment operator into a Visual C++ vector STL? How about other STL implementations? I have tried it on VC++ 6.0, and it does not seem to be possible. Or maybe there's another not-so-straightforward way to do it?
Thanks!
|
|
|
|
|
You can't use such objects with any standard-conforming implementation of the STL. STL containers require that the elements stored in them are copyable by a copy constructor and assignable by the assignment operator.
|
|
|
|
|
No, not by value. In fact, by making the copy constructor and assignment operator private, you are declaring that you cannot copy objects of this type, hence there is no container which can store them by value. You need to store pointers to them.
--
Booohoo!
|
|
|
|
|
Hi , this is my problem if anybody knows that plz give me a use full tips,
Probs:- I have a DLL it contain only resource , I would like to replace one particular string, that is in side resource DLL. But I don’t want to recompile it.
~ Rahuraman.K
|
|
|
|
|
Hope this[^] helps
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
|
To edit resource-containing exe/dll-files, you just need a tool called "Res[ource]Hacker"...
|
|
|
|
|