|
|
Hello,
I would like to use DrawText on top of my application window. The window itself contains a child window. How do I use DrawText on top of both window? I can draw it directly to the screen DC but it's hard to prevent drawing to other windows not belong to my window when my application is partially covered by other application. I also tried to SetWindowLong(m_hParent, GWL_STYLE, GetWindowLong(GWL_STYLE) & ~WS_CLIPCHILDREN); but the text still covered by the child window. Do you have solution for this problem?
Thanks,
Hiusing
|
|
|
|
|
Why not just use the childs DC...??
Obviously i am misunderstanding something...you want to draw overtop of both windows child and parent but also want to make whatever the parent contains visible through the child also...?
MSDN:
If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window.
WS_CLIPSIBLINGS won't do what you desire I don't think
Perhaps create the child window with a NULL brush, this way everything underneath remains visible...
MSDN:
CS_PARENTDC Sets the clipping region of the child window to that of the parent window so that the child can draw on the parent. A window with the CS_PARENTDC style bit receives a regular device context from the system's cache of device contexts. It does not give the child the parent's device context or device context settings. Specifying CS_PARENTDC enhances an application's performance. For more information, seeDevice Contexts.
This might give you the desired effect also so long as your child window returns FALSE in OnEraseBkgnd()
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hello,
I am trying to create a UI thread and use CSocket with in the thread to do a file transfer. I have created my own CWinThread class and a CSocket Class..
I keep getting a error when I try to create the socket inside of the thread.
Here is the error, in debug mode..
void* CMapPtrToPtr::GetValueAt(void* key) const
{
if (m_pHashTable == NULL)<-- HERE
return NULL;
UINT nHash = HashKey(key) % m_nHashTableSize;
CAssoc* pAssoc;
for (pAssoc = m_pHashTable[nHash]; pAssoc != NULL; pAssoc = pAssoc->pNext)
{
if (pAssoc->key == key)
return pAssoc->value;
}
return NULL;
}
In my InitInstance() inside the thread i do a..
BOOL CFtThread::InitInstance()
{
if(!AfxSocketInit())
return FALSE;
return TRUE;
}
and in my "int CFtThread::Run()" I try to Create the socket, thats when I get the error..
Here is how I am trying to create the thread in my main app.. maybe this has something to do with it..
CFtThread* pThread = (CFtThread*)AfxBeginThread(RUNTIME_CLASS(CFtThread),
THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
pThread->m_strAddress = pView->m_strClientDns;
pThread->m_nPort = 21;
pThread->m_strFile = strFilePath;
pThread->m_bAutoDelete = TRUE;
pThread->ResumeThread();
I have seen posts at articles on CodeProject that say that the AfxSocketInit() fixed their problems but I am still having the problem...
Thanks in advance!!
|
|
|
|
|
I just found the answer to my question on microsofts site.. so if anyone else sees this problem heres the work around..
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q193101
Rob
|
|
|
|
|
hi evryone,
i m a beginer VC++ prog.
i have to make a prjct in VC++ for my college project whch will allow access to all desktops in a LAN.
i want to know abt the features reqd to implemnet it and any reference help if avlble.
THNX for any help
|
|
|
|
|
I have a code statements using STL and CString of MFC:
#include <vector>
#include <afx.h>
vector<CString> strs;
vector<CString>::iterator pos;
pos = find(m_lstPy.begin() + nIndexStart, m_lstPy.end(), lpszFind); // Error line
....
The building error:
error C2440: '=' : cannot convert from 'const class CString *' to 'class CString *' Conversion loses qualifiers
|
|
|
|
|
try this:
CString temp = lpszFind;
pos = find(m_lstPy.begin() + nIndexStart, m_lstPy.end(), temp);
or
pos = find(m_lstPy.begin() + nIndexStart, m_lstPy.end(), &temp);
-c
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
the problem is exist yet!!
Please test your code befer place it here!!!
|
|
|
|
|
IMiracle wrote:
Please test your code befer place it here!!!
yes i did. here is the entire program that i used to test it:
#include "stdafx.h"
#include "mfcmfmcc.h"
#include <vector>
#include <algorithm>
#include <afx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
vector<CString> strs;
vector<CString>::iterator pos;
const char * lpszFind = "hi";
pos = find(strs.begin(), strs.end(), lpszFind);
}
return nRetCode;
}
the problem is apparently not in the code you're showing us.
-c
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
Thank you!
What is about mfcmfmcc.h and mfcmfmcc.cpp
|
|
|
|
|
That code is in a MFC Application;
|
|
|
|
|
so was the code i posted.
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
Does anyone know how to retrieve the location of all the icons and shortcuts on the desktop? My program needs to change the display settings at runtime, which may cause icons to be moved around on the Desktop. Once the program is closed, I'd like to restore all the icons and shortcuts to their original locations on the Desktop.
|
|
|
|
|
Just a suggestion...
Check out Mike Dunns articles on Shell extensions...prolly a good place to start.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
how can i tell when the mouse has come over my formview? and when it goes out of the form view? basicly when the cursor is over this view i want to switch my cursor, whenever the mouse goes outside of this area i want to switch it back..
currently i am just overriding OnMouseMove(UINT nFlags, CPoint point) and setting it everytime in here.. the prob is that you can kinda see it flicker when i am running other code at the same time.. i should be able to just set it when it comes in, and set it when it comes out right?
thanks for any suggestions!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
I believe there is a message handle you could override that will update you ask the user moves the mouse into and outside the FormView.
Kuphryn
|
|
|
|
|
Consider overriding OnDragEnter(), OnDragLeave(), and OnDragOver() member functions.
Kuphryn
|
|
|
|
|
these look like they are only for dragging into or out of a view, there is no dragging involved, just coming into and out of a view. thanks for the suggestions tho!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Good point. I cannot think of a message handler that updates as the user moves the mouse into and out of a windows other than getting the update of the mouse handler.
Kuphryn
|
|
|
|
|
Check CWnd::OnSetCursor .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the suggestion! I tried to use this function but it never gets called.. this is a CFormView derived class.. here is what I added in the .h
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
here is what i added in the .cpp
BOOL CDisplayPrintTemplate::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
AfxMessageBox("hrm");
::SetCursor(AfxGetApp()->LoadCursor (IDC_HAND_OPEN));
return 0;
} but it never pops up and says 'hrm'.. any suggestions?
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
To track mouse events use _TrackMouseEvent. It sends to wnd event WM_MOUSELEAVE, when mouse goes out.
Example:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static BOOL bMouseInside;
switch (message)
{
case WM_MOUSEMOVE:
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = hWnd;
tme.dwFlags = TME_LEAVE;
_TrackMouseEvent(&tme);
if(!bMouseInside)
{
bMouseInside = TRUE;
InvalidateRect(hWnd, NULL, FALSE);
UpdateWindow(hWnd);
}
}
break;
case WM_MOUSELEAVE:
bMouseInside = FALSE;
InvalidateRect(hWnd, NULL, FALSE);
UpdateWindow(hWnd);
break;
The second approach is to use timer for periodically checking mouse position. If you received WM_MOUSEMOVE for the first time, you should enable timer, until you detect mouse absence
Example:
BOOL CMouseEvent::OnMouseMove....
{
if( m_uTimer != 0 )
return TRUE;
m_uTimer = ::SetTimer( pWnd->m_hWnd, IDS_TIMER_MOUSE_EVENT, 10, NULL );
if( m_uTimer )
{
m_hWnd = pWnd->m_hWnd;
::SendMessage( pWnd->m_hWnd, UWM_MOUSE_ENTER, 0, 0 );
}
return m_uTimer != 0 ? TRUE : FALSE ;
}
BOOL CMouseEvent::OnTimer(CWnd *pWnd )
{
CPoint pt;
::GetCursorPos( &pt );
if( pWnd != CWnd::WindowFromPoint( pt ) )
{
::KillTimer( pWnd->m_hWnd, m_uTimer );
m_uTimer = 0;
m_hWnd = NULL;
}
return TRUE;
}
|
|
|
|
|
In a thread that i've created with CreateThread i create a window. But when that thread returns the window closes, why? and how can i prevent it?
thanks
|
|
|
|
|
Windows belong to the thread where they are created. You cannot do anything to change this. If you want your window to be more long-lived than the thread, you have not other option but to delegate the creation of the window to another thread (preferrably the app main thread). If you take this approach, take into account all communication between the secondary thread and the windows must be done using SendMessage /PostMessage .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|