Click here to Skip to main content
15,926,507 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: .exe file size increased Pin
Jijo.Raj12-Aug-08 19:36
Jijo.Raj12-Aug-08 19:36 
GeneralRe: .exe file size increased Pin
kDevloper12-Aug-08 19:37
kDevloper12-Aug-08 19:37 
GeneralRe: .exe file size increased Pin
Jijo.Raj12-Aug-08 19:45
Jijo.Raj12-Aug-08 19:45 
GeneralRe: .exe file size increased Pin
kDevloper12-Aug-08 19:58
kDevloper12-Aug-08 19:58 
GeneralRe: .exe file size increased Pin
Jijo.Raj12-Aug-08 20:01
Jijo.Raj12-Aug-08 20:01 
GeneralRe: .exe file size increased Pin
Jijo.Raj12-Aug-08 20:00
Jijo.Raj12-Aug-08 20:00 
GeneralRe: .exe file size increased Pin
kDevloper12-Aug-08 20:23
kDevloper12-Aug-08 20:23 
QuestionQuick question about structure declarations and WinProc messages Pin
Aaron.Morrison12-Aug-08 17:47
Aaron.Morrison12-Aug-08 17:47 
I am new to VC++ programming and have coded for the first time trying to understand Windows messaging. (I am more used to the good old days of Borland's Turbo C++ 3.0)
My question is about structures.. In the snippet below I have defined my structure as such.

In this snippet I have declared the structure in the Window Process DlgProc as static TONE tsTone; which now works for me!! I previously had it declared as just TONE tsTone;.

If I do not declare the structure as static, after populating the members in the IDC_ONOFF: message when the Windows Process is called again, the structure reference in MM_WOM_OPEN: message has rubbish member values and has a different reference address.

My question is - given the struct of TONE tsTone; is declared within the scope of DlgProc why does the structure appear to be volatile and given a new reference address when a different Windows message is processed? If I am using variables that are spread throughout Windows Messages (but still within the scope of the WinProc), should all variables be declared static?

P.S. some reading reference would be very handy if you have it so you don't have to re-invent the wheel.

Aaron.

typedef struct {
	 int itoneEncoding;
	 double dtoneLeadin;
	 double dtoneLength;
	 int iBuffersize;
}TONE, * PTONE;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
    <<SNIP>>
}

BOOL FillBuffer (PBYTE pBuffer, TCHAR * pszToneCode, PTONE tsTone)
{
     int	 iBuffer;
       << SNIP >>
    
        iBuffer = tsTone->iBuffersize;

	// a=49 A=17 - add codition for lower case letters !!
	for(icTone = 0; icTone < 5; icTone++)
	{
        << SNIP >>
		else
			return FALSE;
		
	<< SNIP >>
	return TRUE;
}

BOOL CALLBACK DlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     <<SNIP >>

     static TONE tsTone;

     switch (message)
     {
     << SNIP >>

          case IDC_ONOFF:

                    // Set up TONE structure with variables.
		tsTone.itoneEncoding = iEncoding;
		tsTone.dtoneLeadin = GetDlgItemInt(hwnd, IDC_EDIT_LEADIN, NULL ,FALSE);
		tsTone.dtoneLength = GetDlgItemInt(hwnd, IDC_EDIT_TONELENGTH, NULL ,FALSE);
					

                // calcuate buffer size SAMPLE_RATE * tone length in milliseconds
		// multiplied by 5 for complete buffer size of 5 tones.
		tsTone.iBuffersize = (int)(SAMPLE_RATE * (tsTone.dtoneLength/1000)*5);
        
               <<SNIP>>
               
     case MM_WOM_OPEN:
          SetDlgItemText (hwnd, IDC_ONOFF, TEXT ("Turn Off")) ;

               // Send buffer to waveform output device
          GetDlgItemText  (hwnd, IDC_TONECODE, szToneCode, 6) ;
          if(!FillBuffer (pBuffer1, szToneCode, &tsTone))
		<<SNIP>>
                    
     case MM_WOM_DONE:
	<<SNIP>>
          
      case WM_SYSCOMMAND:
          switch (wParam)
          <<SNIP>>
               return TRUE ;
          }
          break ;

	 }
     return FALSE ;
}


AnswerRe: Quick question about structure declarations and WinProc messages Pin
Jijo.Raj12-Aug-08 18:52
Jijo.Raj12-Aug-08 18:52 
GeneralRe: Quick question about structure declarations and WinProc messages Pin
Aaron.Morrison12-Aug-08 18:55
Aaron.Morrison12-Aug-08 18:55 
QuestionCan we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
CelestialCoder12-Aug-08 17:31
CelestialCoder12-Aug-08 17:31 
AnswerRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
Randor 12-Aug-08 17:52
professional Randor 12-Aug-08 17:52 
GeneralRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
CelestialCoder12-Aug-08 19:45
CelestialCoder12-Aug-08 19:45 
AnswerRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
Rajesh R Subramanian12-Aug-08 19:52
professionalRajesh R Subramanian12-Aug-08 19:52 
GeneralRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
CelestialCoder12-Aug-08 22:14
CelestialCoder12-Aug-08 22:14 
GeneralRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
Rajesh R Subramanian12-Aug-08 23:11
professionalRajesh R Subramanian12-Aug-08 23:11 
GeneralRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
CelestialCoder13-Aug-08 0:25
CelestialCoder13-Aug-08 0:25 
GeneralRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? [modified] Pin
Rajesh R Subramanian13-Aug-08 0:31
professionalRajesh R Subramanian13-Aug-08 0:31 
GeneralRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
CelestialCoder13-Aug-08 1:59
CelestialCoder13-Aug-08 1:59 
GeneralRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
Rajesh R Subramanian13-Aug-08 21:07
professionalRajesh R Subramanian13-Aug-08 21:07 
GeneralRe: Can we use VS2008 to develop a VisualC++ application that runs without dot net frame work? Pin
SandipG 13-Aug-08 1:20
SandipG 13-Aug-08 1:20 
Questionfatal error LNK1120: 1 unresolved externals question Pin
monsieur_jj12-Aug-08 16:06
monsieur_jj12-Aug-08 16:06 
AnswerRe: fatal error LNK1120: 1 unresolved externals question Pin
Mark Salsbery12-Aug-08 16:08
Mark Salsbery12-Aug-08 16:08 
GeneralRe: fatal error LNK1120: 1 unresolved externals question Pin
monsieur_jj12-Aug-08 16:12
monsieur_jj12-Aug-08 16:12 
GeneralRe: fatal error LNK1120: 1 unresolved externals question Pin
Mark Salsbery12-Aug-08 16:16
Mark Salsbery12-Aug-08 16:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.