|
> Now, I want B.EXE to pass a HWND to A.EXE, and A.EXE will draw
> image at the given HWND.
[...]
> I would like get advice from codegurus here whether this
> approach is possible or not.
No.
|
|
|
|
|
Is the HWND just the handle to the main window for B.EXE ? If so, why not just enumerate the windows and find it that way ? Or use Copydata to send the info between processes ?
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hi All,
I am working with VC++(Windows NT).I have created an ATL Service !Now, what I want firstly is that when I run that service, it should not appear in the Task Manager .But, at the background the process should be running ! How can I do that ?Which is the suitable API function for this ?
Thanx in advance for the Help .
Yamini Devi
|
|
|
|
|
Try to look at following adress:
http://www.codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=vc&Number=203057&page=0&view=collapsed&sb=5&category=
Alex
|
|
|
|
|
Hi All,
I am working with VC++.I have created an ATL Service !Now, what I want firstly is that when I run that service, it should not appear in the Task Manager .But, at the background the process should be running ! How can I do that ?Which is the suitable API function for this
|
|
|
|
|
Hi there, can someone give me an idea as to why this code:
/*****************************************************/
/* draw some text */
/*****************************************************/
CRect rect;
CFont TextFont, *oldFont;
CWnd *wnd = GetDlgItem(IDC_PLACEHOLDER); // find where to put the text (a static control)
ASSERT(wnd != NULL);
ASSERT(IsWindow(wnd->m_hWnd) != FALSE);
wnd->GetWindowRect(&rect);
ScreenToClient(&rect);
CPaintDC dc(this) ; // device context for painting
if (m_dc.GetSafeHdc() == NULL)
{
m_dc.CreateCompatibleDC(&dc) ;
m_bitmapTitle.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height()) ;
m_pbitmapOldTitle = m_dc.SelectObject(&m_bitmapTitle) ;
}
TextFont.CreateFont (40, 0, 0, 0, 300, // Create the font
TRUE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
DEFAULT_PITCH|FF_SWISS, "Arial") ;
oldFont = m_dc.SelectObject(&TextFont); // select the font
m_dc.SetTextColor (RGB(128, 0, 0)) ; // set a bunch of attributes of the dc
m_dc.SetBkMode(OPAQUE);
m_dc.SetBkColor(::GetSysColor(COLOR_3DFACE));
m_dc.SetTextAlign (TA_LEFT);
CString Title = "Test ";
m_dc.TextOut(0, 0, Title);
m_dc.SelectObject(oldFont) ;
CDC memDC ;
CBitmap memBitmap ;
CBitmap* oldBitmap ; // bitmap originally found in CMemDC
// create a memory dc
memDC.CreateCompatibleDC(&m_dc) ;
memBitmap.CreateCompatibleBitmap(&m_dc, rect.Width(), rect.Height()) ;
oldBitmap = (CBitmap *)memDC.SelectObject(&memBitmap) ;
if (memDC.GetSafeHdc() != NULL)
{
// draw the text on the memory dc
memDC.BitBlt(0, 0, rect.Width(), rect.Height(),
&m_dc, 0, 0, SRCPAINT) ;
// bitblt the result to the display DC
dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),
&memDC, 0, 0, SRCCOPY) ;
}
memDC.SelectObject(oldBitmap) ;
/*****************************************************/
/* done... */
/*****************************************************/
produces perfectly fine output on Win NT but garbage on win 95/98/Me?? I'm stuck!!
to understand what I mean about garbage, please see Win NT and Win98
Thanks in advance for any help!
Liam O'Hagan
Thanks
Senior Test Engineer
GLI Australia
www.gli.com.au
|
|
|
|
|
Without a real context (not a DC context) it's pretty hard to tell.
I can however tell you that you're in error to not check the return codes from each and every function above why I'd say you deserve the errors. After you've added those checks, perhaps you can see for yourself what went wrong? If not, that would be a good point to ask this question.
P.S.
If you're the "Senior Test Engineer" for that company, would you mind telling me what products you sell so I know what to stay clear of?
|
|
|
|
|
The code I posted was a cut and paste into a demo project, I removed a lot of stuff to make it more readable and easy to see what I was trying to do.
We don't sell any products, so rest assured you need not live in fear of coming across any software that might hurt your pwetty wittle compewter....
I'd be more than happy to tell you the products we test, but wait, what's that?? you're anonymous, silly me...
Thanks for the constructive criticism...
Senior Test Engineer
GLI Australia
www.gli.com.au
|
|
|
|
|
I've rewritten your function, I hope you find it a little neater
/*****************************************************/
/* draw some text */
/*****************************************************/
CRect rcWnd;
CFont TextFont, *oldFont;
CWnd *wnd = GetDlgItem(IDC_PLACEHOLDER); // find where to put the text (a static control)
ASSERT(wnd != NULL);
ASSERT(IsWindow(wnd->m_hWnd) != FALSE);
wnd->GetWindowRect(&rcWnd);
ScreenToClient(&rcWnd);
CDC placeDC;
if (!placeDC.Attach(wnd->GetDC()->GetSafeHdc()))
ASSERT(FALSE);
if (m_dc.GetSafeHdc() == NULL)
{
if (!m_dc.CreateCompatibleDC(&placeDC))
ASSERT(FALSE);
if (!m_bitmapTitle.CreateCompatibleBitmap(&placeDC, rcWnd.Width(), rcWnd.Height()))
ASSERT(FALSE);
m_pbitmapOldTitle = m_dc.SelectObject(&m_bitmapTitle) ;
m_dc.FillSolidRect(0, 0, rcWnd.Width(), rcWnd.Height(), ::GetSysColor(COLOR_3DFACE));
}
if (!TextFont.CreateFont (40, 0, 0, 0, 300, // Create the font
TRUE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
DEFAULT_PITCH|FF_SWISS, "Arial"))
ASSERT(FALSE);
oldFont = m_dc.SelectObject(&TextFont); // select the font
m_dc.SetTextColor (RGB(128, 0, 0)) ; // set a bunch of attributes of the dc
m_dc.SetBkMode(OPAQUE);
m_dc.SetBkColor(::GetSysColor(COLOR_3DFACE));
m_dc.SetTextAlign (TA_LEFT);
CString Title = "Test ";
m_dc.TextOut(0, 0, Title);
m_dc.SelectObject(oldFont) ;
placeDC.BitBlt(0, 0, rcWnd.Width(), rcWnd.Height(), &m_dc, 0, 0, SRCCOPY);
Basically your problem was that a CBitmap created under 98 using CreateCompatibleBitmap is full of random garbage. The line
m_dc.FillSolidRect(0, 0, rcWnd.Width(), rcWnd.Height(), ::GetSysColor(COLOR_3DFACE));
fixes this. You should have had text in the top corner though, but I'm not sure why you did not as I did a partial rewrite to get rid of unnecessary DC's, etc.
Where in Australia are you ? ( I'm in Tassie )
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Thanks Christian, it's good to see that some people are still considerate enough to help another person with their work.
Regards
Liam
Senior Test Engineer
GLI Australia
www.gli.com.au
|
|
|
|
|
I noticed, just today, that IE has an interesting feature when organizing your favourites list. What I noticed is a line appears under an entry when you drag over it. It appears that the line is indicating where the item will be dropped. What this means to me is that a folder can be repositioned within the list rather than becoming a child of the target. I would like to do the same thing but have no idea how. I see this same type of thing in other products, Netscape and DemoShield. Can anyone help me? Try it yourself if you have not experienced this yet!
|
|
|
|
|
Check these methods:
CTreeCtrl::SetInsertMark
CTreeCtrl::SetInsertMarkColor
They're simple wrappers around TVM_SETINSERTMARK and TVM_SETINSERTMARKCOLOR messages, supported on COMCTL version 4.71 and later. Basically this means that target machine must have IE 4.0 or later installed.
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
does anyone know how make a window active when multiple windows are open.
in an mdi applicatin under window menu item there is a list of all open files and the active
one is checked, i want to know how that code works, so that when i click on my tree node
that window should be activated,
Thanks,
F.Dost
|
|
|
|
|
Yeah its pretty easy,
use the SetActiveWindow (hwnd ) function.. You need to get the window handle for the window you want to activate though..
Do that by
hwnd = FindWindow(NULL, "Put the window title here")
SetActiveWindow (hwnd )
|
|
|
|
|
If you are talking about the MDI "document windows", you need to send WM_MDI* messages to the "MDI client", the window that is usually in the dark gray colour.
|
|
|
|
|
Hello, the codegurus around the world.;)
I often use this function from "HOW-TO VISUAL C++ 4.0" by Scott ?
to change the active view on MDI application.
void CMainFrame::SwitchToView(CDocTemplate* pTemplate, CRuntimeClass* pViewClass)
{
CMDIChildWnd* pMDIActive = MDIGetActive();
CDocument* pDoc = pMDIActive->GetActiveDocument();
CView* pView;
POSITION pos = pDoc->GetFirstViewPosition();
while(pos != NULL)
{
pView = pDoc->GetNextView(pos);
if(pView->IsKindOf(pViewClass))
{
pView->GetParentFrame()->ActivateFrame();
return;
}
}
CMDIChildWnd* pNewFrame = (CMDIChildWnd*)
pTemplate->CreateNewFrame(pDoc, NULL);
if(pNewFrame == NULL) return;
pTemplate->InitialUpdateFrame(pNewFrame, pDoc);
}
and call this function anywhere like this.
((CMainFrame*)AfxGetMainWnd())->SwitchToView(theApp.m_pAppTemplate,
RUNTIME_CLASS(CAppView));
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I know how to define flags...
#define FLAG1 0x00000001
#define FLAG2 0x00000002
#define FLAG3 0x00000004
#define FLAG4 0x00000008
#define FLAG5 (FLAG1|FLAG2|FLAG3|FLAG4) //for all
I would also like to have a way that FLAG1 -FLAG4 cant be ORed together expected when ORed together in FLAG5's ()
Any help...
|
|
|
|
|
hey brandon
preventing them from being or'd is simply a case of not writing code that or's them together
you can't stop certain bit combinations from appearing except by not creating them in the first place
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Brandon,
You can't prevent someone from creating a particular value (after all, you don't have physical control over their keyboards ). What you want is an assert in your code that checks the passed-in flags. This will tell the programmer that they have passed you an illegal combo of flags.
void CYourFunction ( DWORD dwFlags )
{
ASSERT( (dwFlags & FLAG1|FLAG2|FLAG3|FLAG4) == FLAG1|FLAG2|FLAG3|FLAG4 ||
(dwFlags & FLAG1|FLAG2|FLAG3|FLAG4) == 0 );
}
This verifies that all or none of FLAG1-4 were passed.
Use ASSERT in MFC code, ATLASSERT in ATL, and _ASSERTE for plain ol' CRT.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Thank you that is what I was looking for.
|
|
|
|
|
I would like to know if there are similar functions as clreol and gotoxy which are not supported by vc++
|
|
|
|
|
What do they do ? In GDI you have MoveTo, is that what gotoxy does ?
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
AFAIK, VC runtime library exposes no such functionality. If you really want to play with text-mode windows/menus, your only hope are low-level console APIs, like WriteConsoleOutputCharacter
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
Hi
I am trying to create my own help topics by modifying afxcore.rtf file, but it doesn't seem to work. I can never get rid of <<add your="" application-specific="" topics="" here="">> message in the Contents tab. Does anyone know why? Could anyone please help me how to add one by one topics to this Help Topics pages?
Thank you very much for your time.
kk9
|
|
|
|
|
I have several controls derived from the COleControl class. With the installation of Office 2000 all of them fail when "inserted" into any of the office applications (Word, Excel, PowerPoint). I have spent some time trying to find what I had corrupted and find nothing wrong. They all worked fine in Office 97. My enviroment is limited to NT4 SP6 for this testing.
This morning I created a new control using the "MFC ActiveX Control Wizard" in VC6. Show as an insertable object was checked in the wizard. Compiled it (with no modification) and I find exactly the same problem. It crashes Office when inserted. The message recieved is "xx has found an error it can not correct. Save, Close and Restart."
I have steped through the initialization code and all looks fine. It never gets to the drawing code. So the failure is somewhere in between these points. From using the debug option when the failure occers it appears that the IsKindOf Function is failing. But this is really info that I can not be sure of exactly where the call is coming from.
So my question is has anyone else seen this response?
Michael A Barnhart
mabtech@swbell.net
|
|
|
|
|