12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

346 Day 9<br />

List<strong>in</strong>g 9.3. cont<strong>in</strong>ued<br />

75: // function LoadStr<strong>in</strong>g(), display the str<strong>in</strong>g,<br />

76: // and tell W<strong>in</strong>dows to repa<strong>in</strong>t the Label<br />

77: //<br />

78: LoadStr<strong>in</strong>g(HInstance, IDS_UP, buff, sizeof(buff));<br />

79: Label->Caption = buff;<br />

80: Label->Refresh();<br />

81: //<br />

82: // play the ‘up’ sound us<strong>in</strong>g the W<strong>in</strong>API function<br />

83: // PlaySound(), play it asynchronously<br />

84: //<br />

85: PlaySound(“ID_WAVEUP”,<br />

86: HInstance, SND_ASYNC | SND_RESOURCE);<br />

87: //<br />

88: // pause for a moment at the top of the jump<br />

89: //<br />

90: Sleep(200);<br />

91: //<br />

92: // repeat all of the above except <strong>in</strong> reverse<br />

93: //<br />

94: for (<strong>in</strong>t i=5;i>0;i--) {<br />

95: Str<strong>in</strong>g resName = s + Str<strong>in</strong>g(i);<br />

96: DrawImage(resName);<br />

97: }<br />

98: PlaySound(“ID_WAVEDOWN”,<br />

99: HInstance, SND_ASYNC | SND_RESOURCE);<br />

100: LoadStr<strong>in</strong>g(HInstance, IDS_DOWN, buff, sizeof(buff));<br />

101: Label->Caption = buff;<br />

102: Label->Refresh();<br />

103: Sleep(200);<br />

104: }<br />

105: }<br />

106: //----------------------------------------------------------<br />

107: void __fastcall TMa<strong>in</strong>Form::StopClick(TObject *Sender)<br />

108: {<br />

109: //<br />

110: // Stop button pressed, so tell the loop to stop execut<strong>in</strong>g<br />

111: //<br />

112: done = true;<br />

113: }<br />

1<strong>14</strong>: //----------------------------------------------------------<br />

115: //<br />

116: // a class member function to display the bitmap<br />

117: //<br />

118: void<br />

119: TMa<strong>in</strong>Form::DrawImage(Str<strong>in</strong>g& name)<br />

120: {<br />

121: //<br />

122: // load the bitmap from a resource<br />

123: // us<strong>in</strong>g the name passed to us<br />

124: //<br />

125: Image->Picture->Bitmap-><br />

126: LoadFromResourceName((<strong>in</strong>t)HInstance, name);<br />

127: //<br />

128: // must pump the message loop so that W<strong>in</strong>dows gets<br />

129: // a chance to display the bitmap

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!