|
In MFC you can't access any CWnd derived objects created in one thread from another, well at least not easilly. You will just get lots of ASSERT's in a Debug build and it simply won't work.
One way to do what you want is to use PostMessage() to post a WM_USER_xx message you define. Post this from the worker thread to the Dlg. In the dialog code add a MsgHandler for the WM_USER_xx msg and get it to call UpdateData(). This will work a treat.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
I appreciate all of your help I think I understand it now, just having a slight problem. How do you make an eventhandler that fires when an integer changes? Again, thanks for all the help.
-Dev578
|
|
|
|
|
First off, remove the calls to UpdateData() , and use member control variables instead. Second, what you've created is a "worker" thread, or a thread with no message pump. A thread with no message pump should in no way be interacting with the UI. That is what a "UI" thread, or a thread with a message pump, is for. In the UI thread, simply post a message to the primary thread, the one that owns the UI, with what's to be updated.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
I too have the same question...
if u find the answer ..plz share with me..
mshiraz@cordiant.net..
thanks a lot...
|
|
|
|
|
This is what I got ur question, so I am pasting the solution , see if it satisfy's you,
step 1) goto Start -> Run
2) Type Regedit
3)Click on
HKEY_CLASSES_ROOT
RIGHT CLIKC ON "*"
INSERT NEW KEY "SHELL" (DO NOT PUT QUOTES """")
RIGHT CLICK ON SHELL
INSERT NEW KEY "oPEN WITH SOMETHING" (DO NOT PUT QUOTES """")
RIGHT CLICK ON "oPEN WITH SOMETHING"
INSERT NEW KEY "COMMAND"
CLICK ON DOUBLE ( YOU WILL SEE (DEFAULT) ON RIGHT HAND SIDE
DOUBLE CLICK ON DEFAULT AND PASTE THE FOLLOWING STUFF
wmPLAYER.exe "%1"
The moment you click on any file you will get following menu!!!
-----------------------
copy
Open with Something
paste
delete
----------------------
this is what you want, I guess, if your question is something else, plz
feel free to re-phrase the question,
cheers
Balkrishna Talele
|
|
|
|
|
This is what I got ur question, so I am pasting the solution , see if it satisfy's you,
step 1) goto Start -> Run
2) Type Regedit
3)Click on
HKEY_CLASSES_ROOT
RIGHT CLIKC ON "*"
INSERT NEW KEY "SHELL" (DO NOT PUT QUOTES """")
RIGHT CLICK ON SHELL
INSERT NEW KEY "oPEN WITH SOMETHING" (DO NOT PUT QUOTES """")
RIGHT CLICK ON "oPEN WITH SOMETHING"
INSERT NEW KEY "COMMAND"
CLICK ON DOUBLE ( YOU WILL SEE (DEFAULT) ON RIGHT HAND SIDE
DOUBLE CLICK ON DEFAULT AND PASTE THE FOLLOWING STUFF
wmPLAYER.exe "%1"
The moment you click on any file you will get following menu!!!
-----------------------
copy
Open with Something
paste
delete
----------------------
this is what you want, I guess, if your question is something else, plz
feel free to re-phrase the question,
cheers
Balkrishna Talele
|
|
|
|
|
Or just call CWinApp::RegisterShellFileTypes() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I need to compile a solution in VC7.1. The solution links with mfcs42d.lib which I obviously don't have. Can I instead link to mfcs71d.lib?
Well actually I tried, but I get a bunch of "LNK2005: XXXXX already defined in msvcrtd.lib(MSVCR71D.dll)"
What can I do about this?
1. Can I make it work with the mfcs71d.lib?
2. Should I get VS6 (is it even possible to get that?) and compile it with that?
3. None of the above......maybe become an accountant instead?
Thanks in advance
|
|
|
|
|
By default, the latest version of MFC is shipped with VC 7.1, and for some "strange" reason, it is not completely backward compatible. I don't know why Microsoft decided to do that, but we'll just have to live with it.
In order to use the VS6 version of MFC, you must get a copy of the necessary library and header files, for example, from one of your friends that is using VS6.
An alternative solution is to convert your program to use MFC 7.1. This might require some alterations to the code, and the fact that you must distribute the MFC 7.1 redist files. So you need to rebuild your installation files to copy the latest MFC redist instead of the older ones.
In conclusion, both choices one and two are possible. The third option is viable too, for it gives more jobs for me
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks for the reply.
Actually I just got it to compile using the VC7.1 libs. Hurray
|
|
|
|
|
Hello all,
I've created an MFC application that has the Topmost attribute set to TRUE by default. It needs to sit ontop of the screen for easy access and other reason. Now I want to be able to give the user the otpion of turning that option on or off. I have included a way for them to do this with a checkbox. The problem is I can't figure out how to toggle this property on and off. If someone could show me how I would appreciate it much.
Thanks,
Justin
There are 10 kinds of people in those world. Those who understand binary and those who don't.
|
|
|
|
|
call SetWindowPos() with HWND_TOPMOST param to make it topmost, and HWND_BOTTOM/HWND_NOTOPMOST/HWND_TOP to remove this property.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Please do see MFC FAQ posted by Michel Dunn, In FAQ he explained how to keep your application ON TOP, or how to toggle it on/off
cheers
Balkrishna Talele
|
|
|
|
|
Thanks for the help guys I found the correct function. It was indeed SetWindowPos. However since I use VS .net 2002 the hwnd has been changed to a cwnd. I just used the cwndTopMost and cwndNotTopMost and it works like a charm.
There are 10 kinds of people in those world. Those who understand binary and those who don't.
|
|
|
|
|
Forgive me if this is a stupid question. I'm a bit of a novice.
I'd like to determine when a network provider is finished installing/initializing and ready to use. My app runs while the provider is being installed. I'm trying to loop as follows:
while(strcmp(netprovider_buf, "NetWare Services") != 0)
{
WNetGetProviderName(
WNNC_NET_NETWARE,
netprovider_buf,
&buffsize
);
}
My idea is when netprovider_buf equals "NetWare Services", I know I can execute the login and successfully login. The problem I'm experiencing is after the first call to WnetGetProviderName in the loop, if NetWare Services hasn't finish initializing, subsequent calls to WnetGetProviderName do not fill netprovider_buf even after NetWare Services does finish initializing. (Sound confusing yet?)
If I don't run my app until after I know NetWare Services is running, then it works fine.
It seems that the MPR somehow blocks the function from working if it fails to return the provider name after the first call. If I close my app after it fails and then re-run it, it does work.
This is all to help improve SLP resolution using NwDskPe http://www.veder.com/nwdskpe/
Thanks for any help
-Trey
|
|
|
|
|
This seems like an awfully "tight" loop, meaning that it is not yielding control of the CPU very often.
That aside, would the following help:
while (strcmp(netprovider_buf, "NetWare Services") != 0)
{
buffsize = size of netprovider_buf here
WNetGetProviderName(WNNC_NET_NETWARE, netprovider_buf, &buffsize);
}
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
u know
id put a timeout in that loop too just in case
and maybe a sleep(200) to yield the cpu
"there is no spoon" biz stuff about me
|
|
|
|
|
Sorry folks,
The code I posted was meant for illustration purposes. In reality I'm only calling the function every few seconds.
My actual code looks something like:
SetTimer(hWnd, timerID, 3000, NULL);
SetTimer is called in my InitInstance function and I'm handling the WM_TIMER message with:
case WM_TIMER:
if(strcmp(netprovider_buf, "NetWare Services") != 0)
{
buffsize = sizeof(netprovider_buf);
WNetGetProviderName(WNNC_NET_NETWARE, netprovider_buf, &buffsize);
}
else
{
strcpy(status, netprovider_buf);
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
KillTimer(hWnd, timerID);
}
break;
I'm sure most of you have an even better way, but none of it works anyhow.
Even when I created a messagebox that would only execute the function when I pressed "OK", still nada. I think this may be a limitation in the Wnet api that I can't overcome, but hopefully I'm just overlooking something.
Thanks for the replies.
|
|
|
|
|
hello everyone.
I have trouble with creating a custom entry point. It's definition is int ExeMain() and it is part of a static library which is linked with the executable.
But when I set the entry point to ExeMain, the linker complains about an unresolved symbol to _ExeMain.
When the ExeMain function is defined directly in a cpp file of the executable it works, but not like that.
Any ideas?
Alex M.
Don't try it, just do it!
|
|
|
|
|
The entry point has to have the __stdcall calling convention and no name decoration. If you just write it as int ExeMain() , it gets name-mangled by the compiler as all C++ functions do.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
|
|
|
|
|
oh... thanks mike!
Don't try it, just do it!
|
|
|
|
|
I have a listview in large icon mode. I need to control the image displayed when item is selected. That is, instead of the default fogging the list view provides, I want to display special "selected" image (known at creation time). Is it possible?
Also, is owner draw mode supported for not report mode?
|
|
|
|
|
I want to know if there is a way to figure out
a perticular dialog is enabe/disable. I use enable
/disable this dialog by the function "EnableWindow(FALSE/TRUE)"
,but before calling EnableWindow, I want to know if this dialog
is disable or enable to hide a bug.
Thanks in advance.
Shin
|
|
|
|
|
IsWindowEnabled() should do the trick!
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|