|
Hi Friends,
How can I Access CDialog Class Member Variables in CDocument Class For Some Process...i Tried a lot..but it give error..plz gve me a solution ..
|
|
|
|
|
What is the relationship between the CDocument and CDialog classes in your project?
|
|
|
|
|
kamalilam wrote: Access CDialog Class Member Variables in CDocument Class
If the member variables are declared as Public, use it directly from the object of the dialog class.
For e.g ,
CDocument* pDoc;
pDoc->m_oDialog.m_nMember1 = 10;
|
|
|
|
|
The same way you would do for any other classes. Your CDialog and CDocument classes are still classes and they follow the same rules as normal classes. So, to be able to access a variable from a CDialog object, you first need to have an instance of that class (e.g. CDialog myDialog, in which case myDialog is your instance). Then your CDocument needs to be able to access that variable (if he create the instance, then he already owns it and can use it). Finally, the members you want to access in your dialog class have to be accessible, which means either they are public or you provide a getter method for them.
But this is really basic C++ knowledge, I suggest you take some time to read and understand the concept of classes, because that's exactly what it is here. It's not because those classes are document and dialog classes that they do not follow the standard rules of C++.
|
|
|
|
|
Will you please include some relevant information in your post?
Are the CDialog members you're talking about public? How is this CDialog object related to the CDocument object in your application?
kamalilam wrote: Tried a lot..but it give error.
*What* did you try and *what* were the errors for Chri' sake?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
I have to return the path of the selected file , EITHER in the Desktop or in the Windows Explorer.
I can get the path of the selected file both on the Windows Explorer and the desktop
My problem is that I am unable to find which window has the current focus
1) The user has selected a file on the desktop
2) The user has selected a file in the Windows explorer. ( So this has the focus now )
How do I programatically find that out
I am using the following code
HWND hWndDesktop = GetDesktopHandle(); // Gets the handle of the SyslistView32 window
DWORD dwThread = ::GetWindowThreadProcessId(hWndDesktop, NULL);
GUITHREADINFO gtf ;
gtf.cbSize = sizeof(GUITHREADINFO);
BOOL b = GetGUIThreadInfo(dwThread, >f);
if(hWndDesktop == gtf.hwndFocus)
{
// this window currently has the focus
}
But I am getting different handles for hWndDesktop and gtf.hwndFocus .
Please let me know if I am missing something
EDIT
I am trying to get the Window handle across processes .
Thanks
Sujay
modified on Friday, December 4, 2009 12:40 AM
|
|
|
|
|
Use GetFocus to get the handle to the window that has the focus.
|
|
|
|
|
HI ,
GetFocus does return me the correct window handle also.
I had tried with GetFoucs,GetActiveWindow, none of them are working
|
|
|
|
|
Superman, Does the GetTopWindow help in this regard ?
Or, What about using File Change Notification[^] to get the changes user made in file system ? Not sure these are relevant for the OP.
modified on Friday, December 4, 2009 1:37 AM
|
|
|
|
|
i have tried what u have done .
that GetFocus function is retirning is NULL when iam calling in thread.
so, that i tried one more function GetForegroundWindow();
this also returns HWND.
CWnd *wnd=NULL;
HWND hWnd = NULL;
CString strwndName;
while (1)
{
hWnd=::GetFocus();
if(hWnd==NULL)
hWnd=GetForegroundWindow();
GetWindowText(hWnd,strwndName.GetBuffer(),20);
dlg->m_ed1.SetWindowText(strwndName);
}
just try it.. it will be work...
Regards,
Srinivas
|
|
|
|
|
Hi,
I'm using VS 2005 and MFC, and I want to modify a system environment variable. So I looked up in the MSDN help and found that it is easy to set a user environment variable. However, for changing a system variable, the help says:
"Calling SetEnvironmentVariable has no effect on the system environment variables. The user can add or modify system environment variables using the Control Panel. To programmatically add or modify system environment variables, add them to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE message. This allows applications, such as the shell, to pick up your updates. Note that environment variables listed in this key are limited to 1024 characters."
I understand that, but find this way very error-prone and complicated. Is there really no easy, straightforward way to do such a simple thing as setting a system variable? No other methods availbale in MFC?
Thanks alot
|
|
|
|
|
That is a better method than I am aware of. I typically modify the registry via code and reboot the computer when necessary.
|
|
|
|
|
Thanks alot, I have now implemented it that way, and I also send the message this way that the environment has changed:
int nVal = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,0,(LPARAM)(_T("Environment")),SMTO_BLOCK | SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG, 5000, &dwReturnValue);
That works for all other processes, i.e. all the other processes that I start after I sent this message know the newly created system variable, and I do not have to restart my system.
However, the process that is currently running, i.e. the process that I used to set this variable is NOT aware of it, so if I make a call to GetEnvironmentVariable after setting it, I do NOT get it. I only get it if I restart the process.
is there a way to know that variable in the same process right after it has been created?
|
|
|
|
|
Erik wrote: is there a way to know that variable in the same process right after it has been created?
Is it responding to the WM_SETTINGCHANGE message?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
use DDK, build resource file (only a ICO file) , but sys file( or res file ) contain "c:\sample\resouce\sample.ico" strings, why ? how to remove it? thanks.
|
|
|
|
|
It is path of the resource in local machine.
res file is intermediate file so wont be a problem just refer [^]
It wont be problem as far as i know.
Величие не Бога может быть недооценена.
modified on Friday, December 4, 2009 12:03 AM
|
|
|
|
|
an unicode MFC project worked well before (VC6), but after I added some COM issues and #include <atlbase.h>, I got compile error:
libcmt.lib(wwincrt0.obj) : error LNK2001: unresolved external symbol _wWinMain@16
project settings are default except unicode info.
how to solve the problem?
thanks
modified on Thursday, December 3, 2009 9:39 PM
|
|
|
|
|
Have you checked here?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Did u checked with the msdn on your machine with this link error.
Set 'wWinMainCRTStartup' on Project Settings-->Link-->Output-->Entry-point symbol:
Величие не Бога может быть недооценена.
|
|
|
|
|
Hi
My software needs a background bitmap image. User will frequently scroll the image. I want to load the bitmap image into memory. So the display performance will improve better.
What function will load bitmap into memory? I am using GDI plus.
void MyView::OnPaint( ... )
{
...
Gdiplus::Graphics gr(dc);
gr.SetPageUnit(Gdiplus::UnitPixel);
gr.DrawImage(pBmp, p, 3);
...
}</pre>
Thanks,
<div class="ForumMod">modified on Thursday, December 3, 2009 6:00 PM</div>
|
|
|
|
|
You can use the Image class to load a bitmap from a file.
|
|
|
|
|
I already load image from a file. But it displays very slow. I want to load data into memory.
Thanks
|
|
|
|
|
Hi there
Can someone please help me. I am looking for a way to measure the speed of my program's execution. I am busy writing a simulation that needs to run as fast as possible and I want to make sure that the algorithms used are the fastest possible. Is there a way or a tool that can be used to measure the speed, like the amount of CPU clock cycles needed to complete an algorithm.
thank you in advance.
Riaan.
KOM UIT DAAAAA!!!
|
|
|
|
|
Have you tried the profiler that comes with Visual Studio?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am not that familiar with visual studio, but I see there is a reference in the help to the profiler. It seems that it would be able to do what I want. I will look in to the profiler.
Thanks for pointing me in the right direction!
KOM UIT DAAAAA!!!
|
|
|
|