|
if i have process name then how to get its id ?
and its window hwnd ?
r00d0034@yahoo.com
|
|
|
|
|
Hi,
I'm trying to place a bitmap of the contents of my CHTMLView Derived class into the clipboard. But all I get when I paste the resulting bitmap is the VC++ IDE behind it.
Heres the code i'm using..
<code><font face="Courier New"><font color="#000000"> <font color="#000080">CRect rect</font><font color="#808080">;
</font> <font color="#000080">GetClientRect</font><font color="#808080">(</font><font color="#000080">rect</font><font color="#808080">);
</font> <font color="#000080">rect</font><font color="#808080">.</font><font color="#000080">NormalizeRect</font><font color="#808080">();
</font> <font color="#0000FF">if</font><font color="#808080">(</font><font color="#000080">rect</font><font color="#808080">.</font><font color="#000080">IsRectEmpty</font><font color="#808080">() || </font><font color="#000080">rect</font><font color="#808080">.</font><font color="#000080">IsRectNull</font><font color="#808080">())
</font> <font color="#0000FF">return </font><font color="#FF0000">0L</font><font color="#808080">;
</font> <font color="#000080">CClientDC dcScrn</font><font color="#808080">(</font><font color="#0000FF">this</font><font color="#808080">);
</font> <font color="#000080">CDC memDc</font><font color="#808080">;
</font> <font color="#0000FF">if</font><font color="#808080">(!</font><font color="#000080">memDc</font><font color="#808080">.</font><font color="#000080">CreateCompatibleDC</font><font color="#808080">(&</font><font color="#000080">dcScrn</font><font color="#808080">))
</font> <font color="#0000FF">return </font><font color="#FF0000">0L</font><font color="#808080">;
</font> <font color="#000080">CBitmap bitmap</font><font color="#808080">;
</font> <font color="#0000FF">if</font><font color="#808080">( !</font><font color="#000080">bitmap</font><font color="#808080">.</font><font color="#000080">CreateCompatibleBitmap</font><font color="#808080">(&</font><font color="#000080">dcScrn</font><font color="#808080">,</font><font color="#000080">rect</font><font color="#808080">.</font><font color="#000080">Width</font><font color="#808080">(),</font><font color="#000080">rect</font><font color="#808080">.</font><font color="#000080">Height</font><font color="#808080">()))
</font> <font color="#0000FF">return </font><font color="#FF0000">0L</font><font color="#808080">;
</font> <font color="#000080">CBitmap</font><font color="#808080">* </font><font color="#000080">pOldBitmap </font><font color="#808080">= </font><font color="#000080">memDc</font><font color="#808080">.</font><font color="#000080">SelectObject</font><font color="#808080">(&</font><font color="#000080">bitmap</font><font color="#808080">);
</font> <font color="#000080">memDc</font><font color="#808080">.</font><font color="#000080">BitBlt</font><font color="#808080">(</font><font color="#FF0000">0</font><font color="#808080">,</font><font color="#FF0000">0</font><font color="#808080">,</font><font color="#000080">rect</font><font color="#808080">.</font><font color="#000080">Width</font><font color="#808080">(),</font><font color="#000080">rect</font><font color="#808080">.</font><font color="#000080">Height</font><font color="#808080">(),&</font><font color="#000080">dcScrn</font><font color="#808080">,</font><font color="#000080">rect</font><font color="#808080">.</font><font color="#000080">left </font><font color="#808080">,</font><font color="#000080">rect</font><font color="#808080">.</font><font color="#000080">top </font><font color="#808080">,
</font> <font color="#000080">SRCCOPY </font><font color="#808080">);
</font> <font color="#0000FF">if</font><font color="#808080">(</font><font color="#000080">OpenClipboard</font><font color="#808080">())
</font> <font color="#808080">{
</font> <font color="#000080">EmptyClipboard</font><font color="#808080">();
</font> <font color="#000080">SetClipboardData</font><font color="#808080">(</font><font color="#000080">CF_BITMAP</font><font color="#808080">,</font><font color="#000080">bitmap</font><font color="#808080">.</font><font color="#000080">GetSafeHandle</font><font color="#808080">());
</font> <font color="#000080">CloseClipboard</font><font color="#808080">();
</font> <font color="#808080">}
</font> <font color="#000080">memDc</font><font color="#808080">.</font><font color="#000080">SelectObject</font><font color="#808080">(</font><font color="#000080">pOldBitmap</font><font color="#808080">);
</font> <font color="#0000FF">return </font><font color="#FF0000">1l</font><font color="#808080">;
</font></font>
</code>
I'm learning DC and painting functions as i'm going any help would be appreciated.
Thanks
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
try moving 'memDc.SelectObject(pOldBitmap)' before the clipboard calls.
i think selecting objects into a dc puts a lock on them until you deselect them; certainly, if you try to delete a bitmap selected into a dc it will not work, so this is worth a try.
|
|
|
|
|
Thanks,
It turned out to be declaring ClientDC instead of using GetDC()
but cheers for the help.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
how come this server code returns with this error.
C:\>tcpserver
We are awaiting a connection on port 5150.
accept failed with error 10014
here is the code where its failing...
<snippet>
// Accept a new connection when one arrives.
if ((NewConnection = accept(ListeningSocket, (SOCKADDR *) &ClientAddr,
&ClientAddrLen)) == INVALID_SOCKET)
{
printf("accept failed with error %d\n", WSAGetLastError());
closesocket(ListeningSocket);
WSACleanup();
return;
}
xai
|
|
|
|
|
This error code means "The system detected an invalid pointer address in attempting to use a pointer argument in a call.". Could post more code, particularly the declaration and initialization of the parameter you pass to accept() ?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
k i figured it out.... everything worked, except that i needed some kind of infinite loop so that it would constantly be looking for connections.
xai
|
|
|
|
|
And I would advise the use of the select() function if you don't want to block on accept() .
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Hi,
I'm using TAPI 2.0 and the wave API to record voice conversations. This seems to work fine with the voice modems that I tried it with, but for some modems, the speaker is silent during the recording process. With other modems, the audio file contains garbage, no matter what audio format I use (I tried 8kHz mu-law and PCM). Is there a driver problem?
Thanks!
--Two Magic Lovers
|
|
|
|
|
Dear Forum,
I have made a MFC application for a client that runs under all windows
os's.
Recently I have added functionality to print to a matrix or line printer
with a special paper size.
However the client must manually add a form (WinNT) or set a special
custom paper size (Win98/95) in which the paper size is defined.
Now I want to programmatically set the paper size.
Does anyone have an idea how to do this?
Greetings
Huub Sepers
|
|
|
|
|
Look at CView::OnPrint(...) and CPrintInfo::m_rectDraw . You may set the print area in OnBeginPrinting . You will have to set the print area in logical units.
Good luck!
ÿVOTD:32 "Whoever acknowledges me before men, I will also acknowledge him before my Father in heaven.33 But whoever disowns me before men, I will disown him before my Father in heaven." - Mat 10:32-33
|
|
|
|
|
Hi All,
I've got an owner drawn combo box, and would like to draw the text in the box in bold, or normally, depending on the value of the DWORD in the item data. If 1, draw it bold, else draw normally.
So, how do I go about doing this? Get the selected font from the DC and modify it?
Thanks,
Aaron
|
|
|
|
|
I would create a new font, that contains the bold text, then select it in to the DC when you are ready to paint. And when you are done, replace the font with the old font. That is because you can never be certain where the DC may come from and you should restore it to its original state when you are finished using a DC.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
1. get the font from the dc (or if thats null then grab a stock font like ANSI_VAR_FONT).
2. then get its logfont:
LOGFONT lf;
pFont->GetLogFont(&lf);
3. then modify the weight:
lf.lfWeight = FW_BOLD;
4. then create your own temp font and use it:
CFont font;
if (font.CreateFontIndirect(&lf))
{
:
:
}
|
|
|
|
|
What do I need to create/compile a _UNICODE MFC application on Win 9x ?
Can some one tell me what files do I need to do this ?
Can some one tell me if a non-unicode application can be run on WinNT ?
Help me ...
Send me an answer as quickly as possible ...
|
|
|
|
|
Chris Maunder has a nice article on how to write Unicode apps called Unicode, MBCS and Generic text mappings[^].
As for the second question, yes, any non-Unicode app will run fine in NT (as a matter of fact, most apps are not Unicode!).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you very much ...
Stefan-Mihai MOGA
mogamihai@home.ro
|
|
|
|
|
My CFormView MFC MDI app needs to know the CREct of the total space occupied by my form. The UI first comes up with scrollbars on the frame, so my form is larger than the CformView form.
Thanks,
ns
|
|
|
|
|
This is not an answer to your question, but I guess it might help: inserting
GetParentFrame()->RecalcLayout();
ResizeParentToFit(FALSE);
by the end of the OnInitialUpdate method of your CFormView -derived class will instruct the whole UI to accomodate to the size of the form, so that no scrollbars appear.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Good try. But it didnt resize the CFormView or the mainframe. It may be a side effect of things I am doing (which I need to do). I have this function:
void CMainFrame::CenterMDIChildWindow(CMDIChildWnd *pWndToCenter)
{
ASSERT(::IsWindow(pWndToCenter->GetSafeHwnd()));
ASSERT(::IsWindow(m_hWndMDIClient));
CWnd* pMDICLIENT = CWnd::FromHandle(m_hWndMDIClient);
if (pMDICLIENT == NULL)
return;
CRect rcChild;
pWndToCenter->GetWindowRect(&rcChild);
CRect rcCenter;
pMDICLIENT->GetClientRect(&rcCenter);
int xLeft =0;
int yTop=0;
pWndToCenter->SetWindowPos(NULL, xLeft, yTop, rcCenter.Width(), rcCenter.Height() ,
SWP_NOZORDER | SWP_NOACTIVATE);
}
which I call as:
pMainFrame->CenterMDIChildWindow(pFrame);
that makes it fit the mainframe.
|
|
|
|
|
Well, I think you should try harder on the ResizeParentToFit path, but anyway. For CScrollView -derived classes (like form views themselves), maybe CScrollView::GetTotalSize is of some use.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
GetTotalSize was exactly what I needed. Now things fit!
Appreciate it!
ns
|
|
|
|
|
My program doesnt like it if you close the CFileDialog Open folder with the right cross menu . I looked at the m_ofn structure but didnt see anything that will suppress this menu. I only want the user to cancel or IDOK.
Any ideas?
Thanks,
ns
|
|
|
|
|
|
I think thats right - have to triple check it. I was doing something in ID_CANCEL that was making it behave inappropriately, and I thought it was a result of the system menu, but it was my fault I think.
Thanks,
ns
|
|
|
|