|
You can raise the probability of the application getting higher CPU cycles, but you can't raise virtual memory beyond a certain limit. You can use a maximum of 2GB out of the 4 GB address space (3GB if you use the /3GB switch).
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Can you writing program a clock by ActiveX control using ATL?
|
|
|
|
|
Hello,
I am attempting to write an app to do the following things:
1) Render DirectX in multiple views of the same document, where the views are created in a static splitter window.
2) Be able to easily synchronize updates between view windows (both windows display time series, want to be able to scroll through time series).
3) Be able to easily control the DirectX stuff (e.g. handle swap chains, window handles, etc.).
I've written most of this already, but not well, and am starting over from scratch (DirectX and synchronizing are handled by going back and forth between MainFrame and view objects).
I was originally trying to create the two views as based on one class (that would handle window specific rendering, other stuff), and make those views members of another class (to handle the DirectX code necessary to render two windows using a single device interface, and to easily synchronize data between the views). However, it seems to me (and I may be wrong) that the dynamic view creation is not capable of this, i.e. I could not create views in a splitter window that were members of another class (but I may be wrong about this, too).
Any suggestions on a clean and robust way to implement something like this? One thought I had was to put the code for dealing with both windows in the CDocument class (since it and the views have inherent access and messaging), but this seems like a kludge.
Any help would be appreciated - please ask me to clarify if the above doesn't seem clear.
|
|
|
|
|
After chasing around the process of calling CMyDialog::OnCreate(), I stopped at CWnd::OnWndMsg
BOOL CWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
...
union MessageMapFunctions mmf;
mmf.pfn = lpEntry->pfn;
...
case AfxSig_is:
lResult = (this->*mmf.pfn_is)((LPTSTR)lParam);
break;
}
Where mmf.pfn is a pointer to CCmdTarget member function. So here MFC assigning
to one field(mmf.pfn) of a union(MessageMapFunctions) with CMyDialog::OnCreate(...) and reading from another(mmf.pfn_is).
What is under the hood, cast between two totally different function signature, is it safe thing to do? Can anybody provides any detail?
|
|
|
|
|
Are you having a problem with calling CMyDialog::OnCreate()? If so, it's unlikely to be related to a bug in in CWnd::OnWndMsg...
Or are you just trying to understand how it works?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi Jose:
I have no problem calling OnCreate(), I just trying to understand the question that in my previous post!
|
|
|
|
|
The MFC message map is just an array of message map structures. When you add a macro to the message map of your class all it does is add a structure to the array.
The macro BEGIN_MESSAGE_MAP(class, baseclass) sets up the message map, and declares the start of the array of AFX_MSGMAP_ENTRY structures.
struct AFX_MSGMAP_ENTRY
{
UINT nMessage;
UINT nCode;
UINT nID;
UINT nLastID;
UINT nSig;
AFX_PMSG pfn;
}; Each entry in the message map adds another entry to the message map array.
For instance, ON_WM_CREATE is defined as
#define ON_WM_CREATE() \
{ WM_CREATE, 0, 0, 0, AfxSig_is, \
(AFX_PMSG)(AFX_PMSGW)(int (AFX_MSG_CALL CWnd::*)(LPCREATESTRUCT))&OnCreate }, So it sets nMessage to WM_CREATE,
nCode, NID, and nLastID to 0,
nSig to AfxSig_is (an enum defined in afxmsg.h - a function that returns int and takes a single parameter that is a pointer)
and pfn is set as a pointer to the function to call.
END_MESSAGE_MAP() simply adds one last entry to the array that is all zeroes, and closes the array declaration.
Now in CWnd::OnWndMsg what happens is that the the code searches through the message map for the class, looking for the entry for the message (WM_CREATE). When it finds it, it gets the sig (AfxSig_is) and uses the sig and the union MessageMapFunctions (defined in afximpl.h) to call the function, complete with the correct parameters and return type.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Then my previous question "...Where mmf.pfn is a pointer to CCmdTarget member function. So here MFC assigning
to one field(mmf.pfn) of a union(MessageMapFunctions) with CMyDialog::OnCreate(...) and reading from another(mmf.pfn_is).Cast between two totally different function signature, is it safe thing to do?"?
|
|
|
|
|
It is like running with sissors. As long as you are careful and know what you are doing, it is perfectly safe. However, one slip and you are in the hospitial.
Technically, you have to look at it from a cost perspective. How many bugs do you track down in a year due to people poorly defining thier function prototypes and thus causing the map to fail? When it does happen, how long do it take to debug the issue? What is the cost of undetected MFC message map problems?
In general, the MFC message maps work just fine. I can't even remember the last time I had a problem with a MFC message map.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
YongSheng Li wrote:
Cast between two totally different function signature
But there is no actual cast involved. mmf.pfn is simply a generic function pointer that can hold a pointer to any function of any class derived from CCmdTarget, and the sig (AfxSig_is in this example) is used to keep track of what the function signature is so that when the function is called it is called with the exact same signature it was saved with. If you would go into the message map and change the sig from AfxSig_is to AfxSig_iis then you would be casting from one function signature to another (from int fnc(char*) to int fnc(int, char*) ) and then you would get errors as this is not allowed.
The trick is that the function pointer is saved in the most generic format possible by downcasting it to a generic CCmdTarget function pointer. But it is upcast back to it's original format before it is used. In effect - no actual cast at all.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I use the activeX MSComm in my program.
But when I send more than 40 bytes data, It will have the assert problem.
In the OnComm() function, I found that it can only loop 40 times when Getting the element.
But in the release mode, it seems to be OK.
However, I can not use the release mode, because other parts of my program have to debug when programming.
Have you ever met this problem?
How did you solve it?
Thanks!
|
|
|
|
|
How to get all zone in the DNS server using VC++? 3X
A poor Coder
|
|
|
|
|
This is source code for .zip file URL:http://www.softty.com/avi2mpg1_ver1_11_src.zip[^].
double click "Avi2mpg1.c" open with VC6,VC6 created a default project workspace,and I linked "vfw32.lib",then build the project,"Output Window" show these error message:
--------------------Configuration: Avi2mpg1 - Win32 Debug--------------------
Compiling...
Avi2mpg1.c
Linking...
Avi2mpg1.obj : error LNK2001: unresolved external symbol _mplex
Avi2mpg1.obj : error LNK2001: unresolved external symbol _avi2mp2
Avi2mpg1.obj : error LNK2001: unresolved external symbol _avi2m1v
Debug/Avi2mpg1.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
Creating browse info file...
Avi2mpg1.exe - 4 error(s), 0 warning(s)
why? Or how to resolve? Please help me?I'll waiting online!
Thank you very much!
|
|
|
|
|
You most likely need to add the other .c files included in the .zip file to your project. The project needs to be configured to generate a console program too.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
|
Other .c and .h files all in the same directory!If I add them to the project,the error message received is more strange:(Can you download the source code(new) and try?
How to resolve?help!Please?
Waiting online......
|
|
|
|
|
include ALL files in the directory and you should be able to compile the code.
Saurabh
|
|
|
|
|
I'm sorry,but I am almost crazy ! Can you try and then answer the question?Please? (
|
|
|
|
|
Thanks! I know how to fix this problem, I'll reinstall VC6.
|
|
|
|
|
I have an application (A) that will execute my application (B) from its menu. When the menu item is selected, a method within my app called Notify will be called to execute the program. It is a COM interface. The problem that I am having is when the menu item is selected, application B executes and creates a named mutex object. The application window does not appear but it proceeds to the Notify method where the application executes once again and tries to create the same mutex object name. It fails because the mutex object already exists. If the mutex was created in the first run, why didn't the application start up? Here is what I have below:
STDMETHODIMP CWrapper::Notify(DataNotificationType notifyType, VARIANT data)
{
STARTUPINFO stStartUpInfo;
PROCESS_INFORMATION *pProcessInfo = new PROCESS_INFORMATION;
memset(&stStartUpInfo, 0, sizeof(STARTUPINFO));
stStartUpInfo.cb = sizeof(STARTUPINFO);
stStartUpInfo.dwFlags = STARTF_USESHOWWINDOW;
stStartUpInfo.wShowWindow = SW_SHOWDEFAULT;
CreateProcess(NULL, "C:\\Program Files\\XXX\\zzz.exe", NULL, NULL, FALSE,
NORMAL_PRIORITY_CLASS, NULL,
NULL, &stStartUpInfo, pProcessInfo);
return S_OK;
}
BOOL CABCApp::InitInstance()
{
mutex = ::CreateMutex(NULL, TRUE, named_mutex);
DWORD dwMutexErr = GetLastError();
if (dwMutexErr == ERROR_ALREADY_EXISTS)
{
CWnd *pPrevWnd = CWnd::GetDesktopWindow()->GetWindow(GW_CHILD);
while (pPrevWnd)
{
if ( ::GetProp(pPrevWnd->GetSafeHwnd(), named_mutex )
{
if ( pPrevWnd->IsIconic() )
pPrevWnd->ShowWindow(SW_RESTORE);
pPrevWnd->SetForegroundWindow();
pPrevWnd->GetLastActivePopup()->SetForegroundWindow();
return FALSE;
}
pPrevWnd = pPrevWnd->GetWindow(GW_HWNDNEXT);
}
return FALSE;
}
Return TRUE;
}
Thanks!
|
|
|
|
|
Hi folks!
I'm workig on a application that needs to Run on Windows Startup. Ok, I just set the registry entry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" to my application, BUT... when the app starts, it loads a dll and this dll load a configuration file in the same dir. When my app loads in startup looks like a shortcut without "Working dir", cause the dll can't load de cfg file.
Does have any way to set the "Working dir" in the registry entry?
Thanks all for the attention
Cheers!
|
|
|
|
|
RickyC wrote:
...cause the dll can't load de cfg file.
Why? Is the DLL making assumptions about the location of the configuration file (i.e., using a relative instead of an absolute path)? If the configuration file and the DLL are always in the same folder, I think the DLL should call GetModuleFileName(NULL, ...) instead of using the current working directory.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
The DLL is a different project. But I will take a look.
Thanks David.
|
|
|
|
|
How do I go about determining the check state of a menu item in a third party app like you can do using the MadCodeHook library?
|
|
|
|
|
Hello,
I was wondering if anyone can help me derive a ctrl that displays data in tournament brackets. I want the control to be derived from the CTreeCtrl since I want the same functionality, just a different way of drawing it. The normal CTreeCtrl draws:
- --Root
|
- --Child1
| |
| - --GrandChild1
| - --GrandChild2
| |
| - --GrandGrandChild1
|
+ --Child2
However, I would like for it to draw like:
-GrandChild1
|
-Child1 --
| |
| -GrandChild2 -- -GrandGrandChild1
|
-Root --
|
+Child2
If anyone can get me started with the code and point me in the right direction, I would greatly appreciate it,
-----------------
Genaro
\\\|
_ _
@ @
_\\
--|
_/
|
|
|
|