|
bdiamond wrote:
However I'm still getting this message for the UI update function that I showed earlier:
Show me the whole function and I'll give it a look.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
here's the function:
void CMainFrame::OnUpdateMaintenance(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
pCmdUI->Enable(theApp.GetAppState() == theApp.BROWSEMODE);
}
I've also tried it with
int i = (int)theApp.GetAppState();
and I still get the same error
[insert witty comment here]
bdiamond
|
|
|
|
|
I think you would be better served my adding three "status" methods to your CBugReporterApp class. Something like:
class CBugReporterApp : public CWinApp
{
public:
bool IsNewMode( void ) { return NEWMODE == m_enumState; }
bool IsEditMode( void ) { return EDITMODE == m_enumState; }
bool IsBrowseMode( void ) { return BROWSEMODE == m_enumState; }
}; Does this help?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Even when I comment out the UI handler code I get the following errors:
error C2143: syntax error :missing ';'before 'CBugReporterApp::GetAppState'
error C2556: 'int CBugReporterApp::GetAppState(void)' : overloaded function differs only by return type from 'CBugReporterApp::MODE CBugReporterApp::GetAppState(void)'
error C2501: 'MODE' : missing storage-class or type specifiers
error C2371: 'CBugReporterApp::GetAppState' : redefinition; different basic types
[insert witty comment here]
bdiamond
|
|
|
|
|
Your header file seems fine. I think the problem is in the implementation of your GetAppState(); (your cpp file). If you dont believe me, try commenting the source within GetAppState(). you wont get any errors.
Try checking that function instead.
Regards,
Maha
|
|
|
|
|
The problem is, as the code is currently written, MODE is a member variable of type _MODE.
You are trying to use this member variable (MODE) instead of the type (_MODE) for parameters and other variables.
Either change the functions to use _MODE instead of MODE
or use a typedef like:
typedef _MODE MODE;
|
|
|
|
|
Never declare anything after using DECLARE_MESSAGE_MAP or DECLARE_DYN* (all the MFC macros) without resetting your access. They change the access setting of your class.
Place a new "public:" prior to the definition of SetAppState and GetAppState.
(Well, that and fixing the _MODE problem which you have already done.)
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
OK, thanks. I will put this in my notekeeper for future reference.
[insert witty comment here]
bdiamond
|
|
|
|
|
My version information is stored in MyProject.rc under the VS_VERSION_INFO . I also have a defined variable with the version info as its value that I use for an about section of the program. Is there a short way (maybe only a few lines of code) to set the File's Properties Version Tab to the value of that variable (i.e. change FILEVERSION and PRODUCTVERSION in VS_VERSION_INFO)? Basically so I don't have to go into the VS_VERSION_INFO and change it each time myself. So on build it reads the variable's value and changes the VS_VERSION_INFO automatically...
|
|
|
|
|
Something like this, perhaps?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
No, I don't want it to actually auto increase the version numbers each time i build the executable. I simply want the key (ie FILEVERSION) to read the value of a variable within the code that I define; so I don't physically have to open up the resource file and change the key for the version in VS_VERSION_INFO. You follow what I mean?
|
|
|
|
|
That article wasn't meant to be a total solution to your problem. It was merely to show you what was invloved in operating on a project's .rc file.
Read the first section of this article.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I appreciate the help. I'll see what I can do with what I've read.
|
|
|
|
|
I just implemented this...try this...
This belongs in your Init for your Help or About Dlg.
edit: the tabs didnt come out to well, but you can adjust!
<br />
CString szAllRights = _T( "All Rights Reserved." );<br />
CString szAppVersion;<br />
CString szComments;<br />
CString szCopyright;<br />
CString szCopyrightWarning;<br />
CString szCompanyName;<br />
CString szAppName = _T( "AppName.exe" );<br />
<br />
DWORD dwVerInfoSize;
DWORD dwVerHnd = 0;
<br />
dwVerInfoSize = GetFileVersionInfoSize( (WCHAR*)(const WCHAR*)szAppName, &dwVerHnd );<br />
<br />
if ( dwVerInfoSize )<br />
{<br />
HANDLE hMem;<br />
if ( ( hMem = GlobalAlloc( GMEM_MOVEABLE, dwVerInfoSize ) ) != NULL )<br />
{<br />
LPSTR lpstrVffInfo; <br />
lpstrVffInfo = (char *)GlobalLock( hMem );<br />
<br />
if ( GetFileVersionInfo( (WCHAR*)(const WCHAR*)szAppName, dwVerHnd, dwVerInfoSize, lpstrVffInfo ) )<br />
{<br />
LPWSTR lpVerInfo;
UINT lpVerInfoLen;
<br />
if ( VerQueryValue( (LPVOID)lpstrVffInfo,<br />
TEXT( "\\StringFileInfo\\040904B0\\FileVersion" ),<br />
(LPVOID*)&lpVerInfo,<br />
&lpVerInfoLen ) )<br />
{<br />
szAppVersion = _T( "Version ");<br />
szAppVersion += lpVerInfo;<br />
SendMessage( GetDlgItem( IDC_VER ), WM_SETTEXT, NULL, (LPARAM)szAppVersion.GetBuffer(MAX_PATH) );<br />
}<br />
else<br />
SendMessage( GetDlgItem( IDC_VER ), WM_SETTEXT, NULL, (LPARAM)_T("") );<br />
<br />
}<br />
}<br />
GlobalUnlock( hMem );<br />
GlobalFree( hMem );<br />
You need a IDC_VER in your dialog that you want to display that information into.
You can also get the strings from other parts of the versioning by using the following:
<br />
VerQueryValue( (LPVOID)lpstrVffInfo, <br />
TEXT( "\\StringFileInfo\\040904B0\\LegalCopyright" ),<br />
(LPVOID*)&lpVerInfo,<br />
&lpVerInfoLen ) <br />
<br />
VerQueryValue( (LPVOID)lpstrVffInfo,<br />
TEXT( "\\StringFileInfo\\040904B0\\CompanyName" ),<br />
(LPVOID*)&lpVerInfo,<br />
&lpVerInfoLen )<br />
Hope this helps
|
|
|
|
|
can someone tell me is there any code/program for erfc (complementary error function) in any of the Visual c++ header..especially the mathematical ones.
or any coding using this function..for my reference
thanx...
|
|
|
|
|
Hey people, I'm developing an application that gets SMS's from a GSM modem and uploads them to a DB. To do this i'm using a CInternetSession object. The app compiles OK but I get a Debug Assertation Error!. I think it has something to do with the internet session object because if I comment out anything to to with the CInternetSession then i don't get the debug error. Infact, simply the 'CInternetSession InternetSession;' declaration at the beginning causes the error alone.
Here's the code. sorry about the spaghetti style code - i'm a bit of a newbie to C++
<br />
#include <stdio.h><br />
#include <afxinet.h><br />
#include "Serial.h"<br />
<br />
#define EVER ;;<br />
<br />
static DWORD listenThread_id;<br />
static DWORD WINAPI listenThread(LPVOID ref);<br />
<br />
<br />
char * command = "AT+CMGR=3\n";<br />
char * delcommand = "AT+CMGD=1\n";<br />
<br />
int count = 0;<br />
<br />
bool appRunning;<br />
bool sendComm, delComm, sendToDB = false;<br />
<br />
CString st;<br />
CInternetSession InternetSession;<br />
<br />
void main()<br />
{<br />
appRunning = true;<br />
<br />
printf("Application Started. Press q to Quit. \n\n");<br />
<br />
printf("Please enter a command. \n\n");<br />
<br />
printf("Press r to read\n\n");<br />
<br />
if (CreateThread(NULL, 0, listenThread, NULL, 0, &listenThread_id) == NULL)<br />
{<br />
exit(-1);<br />
}<br />
<br />
while (appRunning)<br />
{<br />
char inChar = getchar();<br />
<br />
if (inChar == 'q')<br />
appRunning = false;<br />
if (inChar == 'r')<br />
sendComm = true;<br />
if (inChar == 's')<br />
sendToDB = true;<br />
if (inChar == 'd')<br />
delComm = true;<br />
}<br />
}<br />
<br />
static DWORD WINAPI listenThread(LPVOID ref)<br />
{<br />
CSerial Serial;<br />
int port=1, baud=115200;<br />
char lpBuffer[100];<br />
<br />
if (Serial.Open(port, baud))<br />
{<br />
for (EVER)<br />
{<br />
if (sendComm)<br />
{<br />
int commLength = strlen(command);<br />
Serial.SendData(command, commLength);<br />
sendComm=false;<br />
}<br />
<br />
if (delComm)<br />
{<br />
int commLength = strlen(delcommand);<br />
Serial.SendData(delcommand, commLength);<br />
delComm=false;<br />
}<br />
<br />
while (Serial.ReadDataWaiting() > 0)<br />
{<br />
int nBytesRead = Serial.ReadData(lpBuffer, 100);<br />
for (int i=0; i<nBytesRead; i++)<br />
{<br />
printf("%c", lpBuffer[i]);<br />
st += lpBuffer[i];<br />
<br />
int newMsg = st.Find("+CMTI: \"SM\",");<br />
<br />
if (newMsg != -1)
{<br />
count++;<br />
if (count == 2 && lpBuffer[i] != '1')
{<br />
switch(lpBuffer[i])<br />
{<br />
case '2': command = "AT+CMGR=2\n"; delcommand = "AT+CMGD=2\n";<br />
break;<br />
case '3': command = "AT+CMGR=3\n"; delcommand = "AT+CMGD=3\n";<br />
break;<br />
case '4': command = "AT+CMGR=4\n"; delcommand = "AT+CMGD=4\n";<br />
break;<br />
case '5': command = "AT+CMGR=5\n"; delcommand = "AT+CMGD=5\n";<br />
break;<br />
case '6': command = "AT+CMGR=6\n"; delcommand = "AT+CMGD=6\n";<br />
break;<br />
case '7': command = "AT+CMGR=7\n"; delcommand = "AT+CMGD=7\n";<br />
break;<br />
case '8': command = "AT+CMGR=8\n"; delcommand = "AT+CMGD=8\n";<br />
break;<br />
case '9': command = "AT+CMGR=9\n"; delcommand = "AT+CMGD=9\n";<br />
break;<br />
default: command = "";<br />
break;<br />
}<br />
sendComm = true;
st.Empty();<br />
}<br />
if (count == 3 && lpBuffer[i-1] == '1' && lpBuffer[i] == '0')
{<br />
command = "AT+CMGR=10\n"; delcommand = "AT+CMGD=10\n";<br />
sendComm = true;
st.Empty();<br />
}<br />
if (count == 3 && lpBuffer[i-1] == '1' && lpBuffer[i] != '0')
{<br />
command = "AT+CMGR=1\n"; delcommand = "AT+CMGD=1\n";<br />
sendComm = true;
st.Empty();<br />
}<br />
}<br />
<br />
if (st.Find("RING") != -1)<br />
{<br />
st.Empty();<br />
}<br />
<br />
if (lpBuffer[i-1] == 'O' && lpBuffer[i] == 'K' && st.GetLength() > 20)
{<br />
sendToDB = true;<br />
}<br />
}<br />
}<br />
<br />
if (sendToDB)<br />
{<br />
CString s_url = "http://localhost/motm/logvote.php?";<br />
CString s_var = "mess=";<br />
<br />
CString s_urlMessage = s_url + s_var + st;<br />
<br />
char * urlMessage = s_urlMessage.GetBuffer(s_urlMessage.GetLength());<br />
<br />
if(InternetSession.OpenURL(urlMessage))<br />
{<br />
printf("\nSent\n");<br />
st.Empty();
delComm = true;
count = 0;<br />
}<br />
sendToDB = false;<br />
<br />
delete urlMessage;<br />
}<br />
}<br />
}<br />
else<br />
<br />
appRunning = false;<br />
<br />
return 0;<br />
}<br />
<br />
|
|
|
|
|
biggsy14 wrote:
...I get a Debug Assertation Error!.
When the assertion fires, it tells you the line number and file of the offending statement. That should give you a big hint.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks David,
I looked at that and it refers to line 31 of some MFC file. When i press retry on the debug assertation window it refers to getAfxAppName() at line 31 of that file with a yellow arrow in the call stack window. Also in the call stack window is a green arrow referring to line 22 of the code that i posted which is the 'CInternetSession InternetSession;' declaration, and refers to a $E4() method. There is also a window that comes up showing an 'Unhandled Exception' which i'm guessing is what the $E4() is. Any ideas on what to do with this exception?
|
|
|
|
|
biggsy14 wrote:
I looked at that and it refers to line 31 of some MFC file.
It would help to also know the name of the file.
Are you using Visual Studio v6 or .Net?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
Just initialize the CInternetSession Variable with a name.
For example, CInternetSession x("MY APPLICATION");
That should solve your problem.
Regards,
Mahadevan.
|
|
|
|
|
Thanks Mahadevan, that seemed to sort it. Much appreciated!
|
|
|
|
|
Hi,
Attempting to use PlaySound and sndPlaySound on a Win CE PocketPC. The API call returns to say it is a happy chappy and all is well, but I certainly don't get the specified .wav file played ! The file name is correct etc etc
Any idea's?
Interestingly, when I try and play .wav file from Windows explorer they don't sound either.... probably a clue there..!
Thanks
Loz
|
|
|
|
|
Hai Frens,
I need a help regarding MFC.
weather Forms can b inserted in the SDI.
I need to know How to insert with out using App Wizard.
I had an application where in all r programmed by my own With out using app wizard. Which is an SDI application. Now i am in need to insert few controls in that, i Hope With out forms Controls Can not b inserted.
So, Kindly Help me to insert Forms in SDI.
Bye
|
|
|
|
|
AppWizard is used once to create the initial project. After that, you can manually add classes to the project via ClassWizard. To add controls to the dialog template(s), select the ResourceView tab in the Workspace window, expand the Dialog item and double-click on the dialog resource you want to add controls to. Make sense?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi
Does anyone know how to get the list of USB devices connected in machine through c++
thanx in advance
|
|
|
|