|
Like this:
m_menu=GetMenu();
m_menu=m_Menu->GetSubmenu(0);
|
|
|
|
|
Hi all,
This is a question of the form, "why do I type this" instead of "what do I type."
I'm importing some functions from local.dll. I've got a bunch of examples for doing this, and so I start writing these:
typedef int (*My_Function_Name_t)(int, int, char*, int);
typedef bool(*My_Next_Fxn_Name_t)(char**);
...
and then creating function pointers:
My_Function_Name_t My_Function_Name;
My_Next_Fxn_Name_t My_Next_Fxn_Name;
and then setting these to the functions in the dll:
My_Function_Name = (My_Function_Name_t)::GetProcAddress(localdll,"My_Function_Name");
...
Is this the only way to do this? Is there a better or newer way? I'd like to stick to C/C++ (not C# or .NET)
|
|
|
|
|
This is the explicit loading of the dll. It means that you first load the dll 'manually' using LoadLibrary and then retrieve the function pointers you want to call. This gives you some flexibility because you are able to manage the errors (if the dll is not present, LoadLibrary returns NULL, same with functions that don't exist,...).
There's another way which is the implicit loading: you let the compiler 'do the work' for you by including a header file and by linking to a static library both supplied with dll. The static lib contains information about how to load the dll (but not the dll code in itself). This is in general easier but it gives you less flexibility: if the dll is missing when you start your program, a windows error is shown and the program exits (and you can't do anything for it).
I suggest this article[^] if you want to see more in details how to do it.
|
|
|
|
|
As a test run for a much larger and more ambitious program, I have a small application where a user can generate a boolean algebra query from comboboxes of possible values and boolean operators.
Now lets assume that the user has created a syntactically correct expression (we've checked it with some other code), and that all the variables in the expression are valid and can be evaluated. Let's also assume for now that the output of the program window is now a CString which contains the expression with C++ valid boolean operators.
For example, lets say that we have CString expression which contains:
((X && Y) || Z)
Now I want to be able to process that expression and get a result. If I had a line such as:
bool result = ((X && Y) || Z);
I would have my result. Keep in mind that I need to keep this generic so that the user could input as simple or complex a query as needed.
My only thought is to do some awkward string processing to recursively move from any detected parenthesized section, and then have a switch statement or something to perform operations of AND, OR, NOT, etc on a pair of variables, and keep calling this for each found variable, moving outward from inner nested parentheses.
Is there a better way? Again, assuming that the input is "clean", if I somehow could just convert a CString into a code statement, it would process correctly...
Thanks,
Bill
|
|
|
|
|
wolfsburged wrote: bool result = ((X && Y) || Z);
Are you wanting to create this string based on the contents of the comboboxes?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Essentially, yes.
I have comboboxes with the necessary characters in plain text, but need to create the actual query. I can assemble it all into a CString which reads "((X && Y) || Z)" but I need to be able to get bool result = ((X && Y) || Z); out of that.
|
|
|
|
|
Actually it's really not that hard to write an evaluation function for this. Use a stack to push all tokens from left to right. Using the following rules using the above example ((X && Y) || Z)
1. If token is a variable, push its value, else push the token.
2. After each push, check if the top of the stack can be evaluated.
3. After each evaluation, check if the stack can be evaluated further.
4. When no more tokens, the result is in the stack.
When checking if the top can be evaluated:
1. Check for unary operators in stack top - 1
else
2. Check for binary operators in stack top - 1
else
3. Check for parentheses in stack top - 2 and top
(You may also want to check the surrounding values to make sure they are what they are supposed to be, unless you know you have a correct statement syntax)
Example
push (
push (
push X => TRUE
push AND
push Y => FALSE
push )
push OR
push Z => TRUE
push )
There are no more tokens and the result is in the stack. If the stack size is larger than 1, there is an error.
I bet this was not the answer you were hoping for.
|
|
|
|
|
Thank you for the response; I've thought about that approach a bit, and was able to implement it functionally in my project!
|
|
|
|
|
Is it possible to use the VC++ 2008 compiler with Visual Studio 2005, so that you benefit from the smaller code produced by the VC++ 2008 compiler, but yet keep compatibility with Win98 (ie. still use VC++ 2005 runtime libraries) ?
|
|
|
|
|
as long as you don't call specific APIs which Win98 weren't providing yet, yes, you can...
|
|
|
|
|
Do you just copy the relevant compiler files:
c1.dll
c1xx.dll
c2.dll
cl.exe
or should the whole bin folder be copied ?
|
|
|
|
|
either provide every linked dll or static link the dependencies...
but don't copy the compiler itself !!!
humm, it seems i misunderstood your original question. unfortunately, no, you can't use VC++2005 compiler with VS2008 (or vice versa). but you still can compile an application targetting Win98 with VC++2005 or VC++2008
|
|
|
|
|
|
Just use your 2008 and set the _WIN32_WINNT and WINVER variables to indicate that you want to target Win98 (0x0410)
Judy
|
|
|
|
|
|
Didn't notice that change for 2008. Sorry
|
|
|
|
|
Be aware that the smaller code in VS 2008 is probably due to the NOWIN98 linker setting being automatic. In VS 2005 you can set this in the linker optimization properties. Your app will run slightly slower on Windows 98 as a result, but it will run.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
|
Hi, In the past I've used a tool that analyzes a visual studio project's resource.h/rc files to ensure that they are not corrupted. (IE: No two resources share the same the ID.)
Does anyone else know of this tool? I forgot its name.
Thanks!
|
|
|
|
|
|
Hello,
Can anyone please tell me how to add my MDI child windows to the task bar so that when a user has multiple documents open they all appear in the task bar like in Word or Excel. I've tried setting the WS_EX_APPWINDOW style of my CMDIChildWnd derived classes but this doesn't seem to work.
Thanks!
Sylv
|
|
|
|
|
|
Hello,
In eVC++ with WinCE5 on ARMV4I, the application is developed.
In my Property Sheet, in a page, on a button click the program executes the following code.
void CPPage1::GetData() {
bool result = true;
CString csValue;
GetDlgItem(IDC_OpNo_EDIT)->GetWindowText( csValue );
m_opNo = atoi((char*)(LPCTSTR)csValue);
csValue.Format(_T("%d"), m_opNo);
AfxMessageBox(csValue);
OperatorDetails od;
od = g_db->GetOperDetails(m_opNo);
CString s(_T("Map Count = "));
s.Format(_T("%s %d \n %s %s"), s, g_db->GetOperMapCount(), _T("Page1::Got OD"), od.GetOperName());
AfxMessageBox(s);
if (od.GetOperatorNo() == 0 && od.GetOperName() == "") {
AfxMessageBox(_T("Operator No Not found. Check Out!"),MB_ICONWARNING);
result = false;
} else if (od.GetOperName() == "") {
AfxMessageBox(_T("Error Reading Data!"),MB_ICONWARNING);
result = false;
}else {
CString nm = od.GetOperName();
m_name = nm;
GetDlgItem(IDC_NAME_LABEL)->SetWindowText(nm);
AfxMessageBox(nm);
EnableConfirm(true);
}
if (result == false) {
m_opNo = 0;
GetDlgItem(IDC_OpNo_EDIT)->SetWindowText(_T(""));
GetDlgItem(IDC_OpNo_EDIT)->SetFocus();
}
return;
}
g_db is an extern variable pointer to an object. I don't get any compiler/liner etc error or warnings. OnApply is called, everything is executed & then I get "Fatal Application Error" window saying application has performed an illegal operation & will be shut down. If problem continues contact vendor. Exception: 0xC000001D Address: 0050328.
If I avoid the above code, then I don't get this exception. Since it is a WincE with eVC application, I can't debug more to know where & what excatly the error line is. Can anyone help me know, what is illegal in the above code which happens to raise this exception.
Thanks
Terry
|
|
|
|
|
Trupti Mehta wrote: Since it is a WincE with eVC application, I can't debug more to know where & what excatly the error line is.
No, I don't quite get it. Can't you use ActiveSync and debug the application straight from your IDE? You could as well use simple message boxes or a log file to analyze at what point the application terminates.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh, I use eVC++ & run the application via ActieSync. But I believe that I cannot debug in this scenario. Like On Abort/Retry/Ignore, press Retry & the debugger will come on the error line. No that's not possible.
What all AfxMessageBox, you see all are for debugging purpose only mainly.
Thanks
Terry
|
|
|
|