Hi all, Sorry if this has been asked before (I couldn't find anything) but does anyone know if its possiable to use the MSDN collections that come with VC.NET with VC6? All I can find is they are "not compatable", but I was wondering if anyone knew a workaround. Cheers
Diddy
Posts
-
VC.NET Help with VC 6 -
Sending MessageCMyDocument* = (CMyDocument*)GetActiveDocument ();
-
STL debugging in VC++6Add this: std::basic_string<*>= std::vector<*>=size=, capacity= std::map<*>=size=<_Mysize, i> std::set<*>=size=<_Mysize, i> std::list<*>=size= std::deque<*>=size= std::pair<*>=first=, second= std::list<*>::iterator=val=<_Ptr->_Myval> std::list<*>::const_iterator=val=<_Ptr->_Myval> std::_Tree<*>::iterator=val=<_Ptr->_Myval> std::_Tree<*>::const_iterator=val=<_Ptr->_Myval> To VSDir\Common\MSDev98\Bin\Autoexp.dat That will give you some more info on the stl types. To actually see the contents of a vector, say called m_vec, you can actually take the address of the first element to be equal to the address of an standard C array stored in the vector - say &m_vec[0]; This is because STL gaurentees that the vector occupies contigous memory. If m_vec was a vector of ints (and your using STL port), you can do this: ((int*)&m_vec[0]), 100 to expand 100 elements in the vector in the watch window. Unfortunatly, standard stl wont let u call [] operator in the watch window. You can do ((int*)&(*m_vec.begin())), 100 If you can remeber all that lol
-
Sending MessageFrom the main frame, get the document to iterarate round all the current views (CDocument::GetFirstViewPosition & CDocument::GetNextView. Add a OwnsObject function to each view, and call it for each view. In that function, have the view check to see if it owns the supplied object ID.
-
Moving dialog windowIt should :confused: This: UINT CSssDlg::OnNcHitTest(CPoint point) { CRect rc; GetClientRect(&rc); ClientToScreen(&rc); return rc.PtInRect(point) ? HTCAPTION : CDialog::OnNcHitTest(point); } Does. In the dialog its self - with ON_WM_NCHITTEST() added to the dialogs messgae map
-
troubles with templatesBecause templates are expanded as they are compiled - just including the .h with the function declared (not defined) is not enough This is the pain the arse problem that you usually have. Really, its much easier if you stick to the thin template pattern - short template code. Then, put it in at the same time as decliration - as in b). If you really want to split it up - you can put the defination at the bottom of the .h its declared in. Or, if you really want the defination in a .CPP file - you can (uck) #include the .CPP into the other CPP you are using the template in.
-
Windows Platform SDKErrrrrrrrrrr. If your talking about VC6 - that was shiped in 98. If you set WINVER to 0x500 to target Win 98 and 2k, you will get a message saying that the headerd included with VC6 are for the BETA versions of these OS's. Yes, you don't need to install the new platform SDK for most things. But the one that comes with VC6 can only really be used to offically target NT and 95.... Anything that 98 has and 95 doesn't, you should use a newer SDK.
-
Update Edit Box textTry it - it doesnt. Yes SetDlgItemText changes the text - though really its the Win32 way of doing things. The way he has done it with UpdateData basically calls SetDlgItemText anyway under the hood - just using the DDX/DDV map to work out what to map to what. But just like UpdateData, SetDlgItemText will set the text after the loop has returned. If you are processing a message spinning in a loop then no other messages will come through when you are doing that (specifically, WM_PAINT's) until you return from that loop. Hence, yes u have changed the text in the edit box with SetDlgItemText but the edit box wont redraw until your function returns.
-
How to use lstrcpy?LPCTSTR pszString = "Hello"; TCHAR szCopyTo[100]; ::lstrcpy(szCopyTo, pszString); Result = szCopyTo = "Hello"
-
Update Edit Box textNo problem :)
-
Update Edit Box textWont help. If your looping around in that one function, you can do what you want to the other edit box, it wont redraw until you return from that function and contine to pump messages.
-
Update Edit Box textEither: Do each thing in a different thread. Or (more simply for this case) Pump messages in your loop. Change your loop to: while (total < max ) { //Do something with value from Edit Box 1 sprintf(tmpStr,"User message %i", total/1024); UpdateData(false); if(!PeekAndPump()) break; m_editStr2 = _T(tmpStr); //feedback the result to Edit Box2 Sleep(200); UpdateData(false); } Then add this function to your class: BOOL PeekAndPump() { MSG dlgMsg; if (::PeekMessage (&dlgMsg, NULL, 0, 0, PM_NOREMOVE)) { if (!AfxGetApp ()->PumpMessage ()) { ::AfxPostQuitMessage (0); return FALSE; } return TRUE; } LONG lIdle = 0; while (AfxGetApp ()->OnIdle (lIdle++)); return FALSE; }
-
VS.NET CD's --> DVDI know this isn't strictly a Visual C++ Q, but I haven't had much luck else where :o) Has anyone ever managed to combine the VS.NET CD distribution (7 CD version, 2002 Enterprise Archect) onto one DVD? I have created a network install, as per readme file, and everything works fine from the HDD. Copy that onto a DVD, try to install, the install starts, gets about 6% through - then starts asking for me to "Insert CD1". I don't suppose anyone has ever managed to do this? Long shot I know. Ta.
-
How to open new windows at the top of z-order, when process is not current process ?- Yes :o) Thats called me trying to attack the situation with copy and paste :o) Well spotted. 2) No. It's not stealing its input - its stealing - or rather sharing - its input states. Each thread has a number of states associated with all the windows it has created - such as the one that has the focus, and the curent cursor for each etc. When you call SetFocus, it says is the focus state set for our thread for at least one window we have created - if thats a no, it does nothing - if its a yes, it sets the focus to the window provided. AttachThreadInput simply combins the states for both threads, so thread A and thread B are now working with the same state - since you are attaching to the current forground window, your focus state is now set and you can change the focus to one of your own windows. In other words: defenestration wrote: This means that certain messages, received during the time that my app has the other apps thread input, will not be handled by the other app Isn't true - its nothing to do with the messages - just to do with certian states of the thread (specifically focus, active, capture windows, key state, queue status, and so on). It's the recomended way by MSDN anyway - and I have used it for ages with no stabality problems. One thing to be aware of - never put a break point between attaching and detacting. If you are debuging - you will be attaching to MSDEVS thread, and because your app is being debugged, you will be bascially freeze the debugger. Hope it helps
-
Need Urgent Help for a listener catching tooltipsYou mean catch _all_ tooltips? Even from other apps? Look up windows hooks, start at SetWindowsHookEx - you will need to intercept all messages for all processes (though you may be able to use a CBT hook and just check for the window class equal to TOOLTIPCLASSA\TOOLTIPCLASSW) and work out when a tool tip is created and dispayed and get the text from it.
-
Detected memory leaks! - How to get the point of memory leak and remove it:) Well they gets two answers to their Q not just one - effeciant this CP message board eh.
-
Converting Integer to POSITION?A POSITION is like an iterator for a collection - its not synomous with an integer. The CTypedPtrMap will be keyed by what ever you templateized it on - looking at this a string. So you can find your CContact based on a CSring easily, which is the key into the map. How did you insert into the map? Did you insert all the keys into m_screenName, then insert each CContact into the map based on the key? If so, you can do a GetText on the combo to get the text for item iIndex, then use that look up in the map. CString str; str = m_screenName.GetText(iIndex); CContact* p = NULL; BOOL b = m_Contacts.Lookup(str, p); etc If not, the only thing u can do is to advance around the map until u hit the position at iIndex: POSTION pos = m_Contacts.GetStartPosition(); int nElement = 0; while(pos != NULL && nElement++ <= iIndex) { pos = m_Contacts.GetNextAssoc(pos, strKey, pContact); } You get the idea - iterate around the map until you get to element iIndex.
-
Detected memory leaks! - How to get the point of memory leak and remove itYou usually find the memory leak by simply clicking on the line reported say strcore.cpp(118) But, if that file resides out side your project, as strcore.cpp does (its part of MFC) it wont work. The second leak should "D:\Documents and Settings\erc\Desktop\Pattern\DBManager.cpp(32) " Double click it and it will take you to where it was allocated. As for the first, you have a leak via a CString somewhere.
-
How to open new windows at the top of z-order, when process is not current process ?If i understand what you mean (you asking how to steal input focus on 2K/XP if a window belonging to another process has the focus) You need to attach your threads input Q to the active windows input Q - other wise as you say SetForgroundWindow does nothing. Like this: AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(),NULL), GetCurrentThreadId(),TRUE); SetForegroundWindow(); SetFocus(); AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(),NULL), GetCurrentThreadId(),FALSE); That will attach ure threads input Q to the input Q of the window with the foucs, steal the focus - which is now allowed, then detach it. I hope thats what u ment :o)
-
Waiting for ShellExecute before going onI take it you mean each step is running on its own thread? Semaphores dont help you gaurentee order. All the do is protect say thread A accessing the same thing as thread B. Which order thread A and thread B run in is down to the scheduler. So it might happen A grabs the semaphore, B tries to and waits, A releases semaphore, B contnues to run. Or it might happen B grabs the semaphore, A tries to and waits, B releases semaphore, A contnues to run - its up to the scheduler (and of course your theads priority). If you want things to happen one after the other, run them on the same thread: void Foo( { Step1(); Step2(); Step3(); } etc. If you really want each step to happen on it's own thread, then you need to use events. Look up CreateEvent/SetEvent/ResetEvent If I have the wrong end of the stick, and what you are asking is you want ShellExecuteEx not to return until the spawned process has finished, you do it like this. SHELLEXECUTEINFO si; si.fMask = SEE_MASK_NOCLOSEPROCESS; si.etc etc ShellExecuteEx(&si); WaitForSingleObject(si.hProcess, INFINATE);