|
|
I would like to press a button in an mfc application and bring another application to the top. I searched the documentation and found commands like SetForegroundWindow() and ActivateWindow(), but I only made it that the application blinks in the task bar (Win 2000). Can anyone tell me a solution of this problem. It must be working with VC6/VC7(2003) on Win 2000 and NT 4.
|
|
|
|
|
Clicking a button in your app will give it focus, so you need to do this after the button up message. BringWindowToTop() should do the trick.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Starting with Win2000, MSFT desided to restrict ability of not active application to become active (to fight those IE popups).
I'll recommend looking into AllowSetForegroundWindow to understand invented concept.
However, there are several workarounds that can do the trick -- It's not allowed to post them here, but if you email me I'll share them with you...
Regards
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Why are you not allowed to post them here?
Thank You
Bo Hunter
|
|
|
|
|
Why are you not allowed to post them here?
Because, by doing that I'll be directly undermining MSFTs security efforts and eventually may get into trouble.
In my opinion, this site is directly or indirectly financed by MSFT: why would I post materials undermining MSFTs security efforts on MSFT site?
Regards
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
My solution is different, but actually there is an article here that may help you:
http://www.codeproject.com/dialog/dlgboxtricks.asp?target=attachthreadinput
Regards
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Hi,
I might have posted a similar question earlier, but didn't get any answer. In my SDI application I have a tree control, which is loaded from a xml document. While loading part of the document becomes grayed, if I minimize the application and restore again, the gray portion goes away. Sometimes, when there is no gray portion in the tree control minimizing and restoring creates gray portion in the tree control, but there is no specific rule by which it happens. Was wondering why it is happening, can anybody help?
Thanks
|
|
|
|
|
Has anyone encountered a strange error in VC6, in which suddenly code starts crashing when accessing comctl32. For me it crashes in debug mode as soon as the menu in an app is mouse-overed. Everything seems fine until this seemingly random point in time.
J.
----------------------------
|
|
|
|
|
No, never. I would stronly suspect your code is screwing something up. If you check the stack backtrace in the Debugger you might get some clues.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
I would stronly suspect your code is screwing something up.
It is possible - but it doesn't seem like it. This occurs out of the blue. If there is one thing about the computer they are consistant - The code works, then at some point it starts crashing while in debug mode. Something is causing this sudden problem - and it doesn't seem to be anything that I have done differently. I will check the stack next though
J.
----------------------------
|
|
|
|
|
Reinstalled Windows and it is working properly again.
J.
----------------------------
|
|
|
|
|
Drastic measure, glad to hear it did the trick.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
JWood wrote:
Has anyone encountered a strange error in VC6, in which suddenly code starts crashing when accessing comctl32. For me it crashes in debug mode as soon as the menu in an app is mouse-overed. Everything seems fine until this seemingly random point in time.
I used to see this happen all the time when developing under Windows 95 and later 98. I've never seen it happen under 2000/XP (all I've developed under for a while now). It never seemed to be related to errors in my code, and it never happened when running my app standalone--ONLY when running under the debugger. I could never correlate it with anything in particular. It would happen frequently for a while, then I wouldn't see it for weeks, sometimes months. Very odd.
Also, it did a lot more than screw up the app I was running, mousing over icons on the Windows Taskbar caused it to crash, and any tooltip anywhere in the system (or other apps, including DevStudio) would make it crash. The only solution was to reboot.
So I can't really offer an explanation, or a solution. But it sounds like it might be the same thing. My ultimate solution was to never use the abomination that is 9x/ME again
|
|
|
|
|
So what does XP / 2000 bring to the game that was lacking in 9x?
J.
----------------------------
|
|
|
|
|
How are you guys using WTL in brand new VC7 projects? The compilation fails because of _Module being undefined. I tried using all crap like
#define _Module (*_pAtlModule)
It didnot solve all teh problems though. I had to create a fake module class to do that. Is there a simpler way anyone is using? If not will this be an article material?
Somewhere in the world there is a machine language programmer waiting for that damned assembly language fad to pass. - Stan Shanon
|
|
|
|
|
Stick the following in your stdafx.h file:
#include <atlapp.h>
extern CAppModule _Module;
|
|
|
|
|
Hi,
SafeArrayGetUBound function sets the upper bound to -1. but it returns S_OK. the safeArrayAccessData function also returns S_OK.
this happens only under win 98. everything is ok under win NT 4 and win XP. I use MSComm control and m_comm is a pointer to that. the MSComm object always exists in my dialog based application and is always in binary input mode. It sends 6 byte binary data successfully, but it cannot get the coming 6 bytes.
i need to get each byte of the coming data. i cannot make a big change in the way of receiving the data (i will continue with MSComm) because, I am all finished except for win98.
does someone know a way to fix this problem?
thanks in advance
--------
Here is some of my code:
.
.
.
COleVariant vVar;
dlg_p->m_comm.SetOutput(var_rb); // data sent
Sleep(50); // wait
vVar = dlg_p->m_comm.GetInput(); // received
//vVar.Attach(dlg_p->m_comm.GetInput()); // this doesn't change anything
Sleep(50); // wait
long lLen;
unsigned short data = 0;
HRESULT hr = SafeArrayGetUBound(vVar.parray,1,&lLen);
if(hr == S_OK)
{
lLen++;
UCHAR *pAccess;
hr = SafeArrayAccessData(vVar.parray, (void**)&pAccess);
if(hr == S_OK)
{
// under win98 lLen is 0 here.
if(lLen==6)
// stuff with pAccess[]
SafeArrayUnaccessData(vVar.parray);
}
}
.
.
.
----------
|
|
|
|
|
Hi All
i have a edit control, which i use to display text, within this text there
is usually a web address.
is it possible for me to make this a hyperlink ? or display a hyperlink
within a text box ??
thanks
si
|
|
|
|
|
Have you considered a rich-edit control?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
you'd better custom-draw your edit control
|
|
|
|
|
As David posted earlier, you could do this with a RichEdit control.. Here's how I have done it in the past.. the example is using a RichEdit control in a dialog box..
unsigned mask = m_cRichEdit.GetEventMask();
m_cRichEdit.SetEventMask(mask | ENM_LINK);
m_cRichEdit.SendMessage(EM_AUTOURLDETECT,TRUE,0);
if(message == WM_NOTIFY)
{
if(((LPNMHDR)lParam)->code == EN_LINK)
{
ENLINK* p = (ENLINK *)lParam;
if (p->msg == WM_LBUTTONDOWN)
{
ENLINK* p = (ENLINK *)lParam;
m_cRichEdit.SendMessage(EM_EXSETSEL, 0, (LPARAM)&(p->chrg));
m_cRichEdit.SetSel(p->chrg);
CString strLink = m_cRichEdit.GetSelText();
ShellExecute(NULL, "open", strLink, NULL, NULL, SW_SHOWNORMAL);
}
}
}
Don't forget to do a AfxInitRichEdit(); inside the Init of the APP..
Hope this helps,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I have a C program that has some static arrays of Number/String pairs (error number to descriptive text mapping). I thought that this would be great to have in a C++ collection class (std::map, or CMap in windows). Now apart from the weird template syntax, this would work nicely.
However, to initialise the collection class, I have to run an initialiser function that loads in the collection entries, either as hard-coded values in the source code, or by reading a file.
In the case of hard-coded values in the source code, the application ends up with two copies of the data in memory. Not as efficient as old C static arrays.
In the case of file reading, there is the overhead of the load procedure.
IS there any way, or proposed C++ standard, to initialise a collection/classes at compile-time - so you could pre-fill the data elements as easily as you can currently define array elements?
|
|
|
|
|
One solution is a DLL. Initialize the containers in the class contructor.
Kuphryn
|
|
|
|
|
I've been handed some code in Matlab to
convert to c++. Although I am familiar with Matlab,
I have come across:
while 1 % forever do...
% carry out a calculation
end % end forever do
with no obvious termination condition. My question
is, how will this loop ever terminate as I need
the c++ function version of it to eventually return
a value? I suspect I should be looking for a
return or break statement
but can't seem to locate one inside the while loop.
I am thinking this loop is not coded correctly, but
have been assured that it works...
I'm not exactly a Matlab Guru, so maybe I am missing
something?
John Theal
Physicist/Mathematical Programmer
Digital Immersion Software Corporation
Got CAD?
http://www.presenter3d.com[^]
http://www.merlin3d.com[^]
|
|
|
|