📄 fg__win32drawinterface_8cpp-source.html
字号:
00129 HPEN hPen = CreatePen(PS_SOLID, 1, color);00130 00131 HPEN hPenOld = (HPEN)SelectObject(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, hPen);00132 00133 MoveToEx(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, x1, y1, <a class="code" href="group__Utility.html#ga11">NULL</a>);00134 LineTo(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, x2, y2);00135 <span class="comment">// Win32的画线函数不画最后一点,和FishGUI的定义不同</span>00136 <span class="comment">// 这里需要加画最后一点</span>00137 SetPixel(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, x2, y2, color);00138 00139 <span class="comment">// 删除绘图资源</span>00140 SelectObject(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, hPenOld);00141 DeleteObject(hPen);00142 }00143 }00144 00145 <span class="comment">//##ModelId=3F4EDED1031E</span><a name="l00146"></a><a class="code" href="classFG__Win32DrawInterface.html#a7">00146</a> <span class="keywordtype">void</span> <a class="code" href="classFG__Win32DrawInterface.html#a7">FG_Win32DrawInterface::DrawText</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * Text, <span class="keyword">const</span> <span class="keywordtype">short</span> x, <span class="keyword">const</span> <span class="keywordtype">short</span> y, <span class="keyword">const</span> <a class="code" href="group__Color.html#ga0">COLORVAL</a> color)00147 {00148 <span class="keywordflow">if</span> (<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>)00149 {00150 SetTextColor(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, color);00151 SetBkMode(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, TRANSPARENT);00152 TextOut(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, x, y, Text, strlen(Text));00153 }00154 }00155 00156 <span class="comment">//##ModelId=3F4EDED200DA</span><a name="l00157"></a><a class="code" href="classFG__Win32DrawInterface.html#a8">00157</a> <a class="code" href="group__Utility.html#ga1">WORD</a> <a class="code" href="classFG__Win32DrawInterface.html#a8">FG_Win32DrawInterface::GetTextWidth</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * Text)00158 {00159 <span class="keywordflow">if</span> (<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>)00160 {00161 SIZE size;00162 GetTextExtentPoint(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, Text, strlen(Text), & size);00163 <span class="keywordflow">return</span> (<a class="code" href="group__Utility.html#ga1">WORD</a>)size.cx;00164 }00165 <span class="keywordflow">else</span>00166 <span class="keywordflow">return</span> 0;00167 }00168 00169 <span class="comment">//##ModelId=3F4EDED20184</span><a name="l00170"></a><a class="code" href="classFG__Win32DrawInterface.html#a9">00170</a> <a class="code" href="group__Utility.html#ga1">WORD</a> <a class="code" href="classFG__Win32DrawInterface.html#a9">FG_Win32DrawInterface::GetTextHeight</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * Text)00171 {00172 <span class="keywordflow">if</span> (<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>)00173 {00174 SIZE size;00175 GetTextExtentPoint(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, Text, strlen(Text), & size);00176 <span class="keywordflow">return</span> (<a class="code" href="group__Utility.html#ga1">WORD</a>)size.cy;00177 }00178 <span class="keywordflow">else</span>00179 <span class="keywordflow">return</span> 0;00180 }00181 00182 <span class="comment">//##ModelId=3F4EDED20239</span><a name="l00183"></a><a class="code" href="classFG__Win32DrawInterface.html#a10">00183</a> <span class="keywordtype">void</span> <a class="code" href="classFG__Win32DrawInterface.html#a10">FG_Win32DrawInterface::DrawBitmap</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * pBmpName, <span class="keyword">const</span> <span class="keywordtype">short</span> x1, <span class="keyword">const</span> <span class="keywordtype">short</span> y1)00184 {00185 <span class="keywordflow">if</span> (<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>)00186 {00187 HBITMAP hBitmap1 = (HBITMAP)LoadImage(<a class="code" href="group__Utility.html#ga11">NULL</a>, pBmpName, IMAGE_BITMAP, 0, 0,00188 LR_DEFAULTSIZE | LR_LOADFROMFILE);00189 <span class="keywordflow">if</span> (hBitmap1)00190 {00191 BITMAP info;00192 GetObject(hBitmap1, <span class="keyword">sizeof</span>(BITMAP), & info);00193 00194 HDC hMemDC1 = CreateCompatibleDC(<a class="code" href="classFG__Win32DrawInterface.html#p0">m_hDC</a>);00195 SelectObject(hMemDC1, hBitmap1);00196 BitBlt(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, x1, y1, x1 + info.bmWidth - 1, y1 + info.bmHeight - 1, hMemDC1, 0, 0, SRCCOPY);00197 DeleteDC(hMemDC1);00198 DeleteObject(hBitmap1);00199 }00200 }00201 }00202 00203 <span class="comment">//##ModelId=3F6193B201F2</span><a name="l00204"></a><a class="code" href="classFG__Win32DrawInterface.html#a11">00204</a> <span class="keywordtype">void</span> <a class="code" href="classFG__Win32DrawInterface.html#a11">FG_Win32DrawInterface::DrawPolyLine</a>(<span class="keyword">const</span> <span class="keywordtype">short</span> n, <span class="keyword">const</span> <a class="code" href="structFG__Point.html">FG_Point</a> * vert, <span class="keyword">const</span> <a class="code" href="group__Color.html#ga0">COLORVAL</a> color)00205 {00206 <span class="keywordflow">if</span> (<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>)00207 {00208 <span class="comment">// 创建绘图所用资源</span>00209 HPEN hPen = CreatePen(PS_SOLID, 1, color);00210 00211 HPEN hPenOld = (HPEN)SelectObject(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, hPen);00212 00213 POINT * lppt = <span class="keyword">new</span> POINT[n];00214 <span class="keywordflow">for</span> (<span class="keywordtype">short</span> i = 0; i < n; i ++)00215 {00216 lppt[i].x = vert[i].<a class="code" href="structFG__Point.html#o0">x</a>;00217 lppt[i].y = vert[i].<a class="code" href="structFG__Point.html#o1">y</a>;00218 }00219 00220 Polyline(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, lppt, n);00221 SetPixel(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, lppt[n - 1].x, lppt[n - 1].y, color);00222 00223 <span class="keyword">delete</span> [] lppt;00224 00225 <span class="comment">// 删除绘图资源</span>00226 SelectObject(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, hPenOld);00227 DeleteObject(hPen);00228 }00229 }00230 00231 <span class="comment">//##ModelId=3F6EAC820075</span><a name="l00232"></a><a class="code" href="classFG__Win32DrawInterface.html#a12">00232</a> <span class="keywordtype">void</span> <a class="code" href="classFG__Win32DrawInterface.html#a12">FG_Win32DrawInterface::DrawDotRect</a>(<span class="keyword">const</span> <a class="code" href="structFG__Rect.html">FG_Rect</a> & rect, <span class="keyword">const</span> <a class="code" href="group__Color.html#ga0">COLORVAL</a> color)00233 {00234 <span class="keywordflow">if</span> (<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>)00235 {00236 <span class="comment">// 创建绘图所用资源</span>00237 HPEN hPen = CreatePen(PS_DOT, 1, color);00238 00239 HPEN hPenOld = (HPEN)SelectObject(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, hPen);00240 HBRUSH hBrushOld = (HBRUSH)SelectObject(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, GetStockObject(NULL_BRUSH));00241 00242 Rectangle(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, rect.<a class="code" href="structFG__Rect.html#o0">wLeft</a>, rect.<a class="code" href="structFG__Rect.html#o1">wTop</a>, rect.<a class="code" href="structFG__Rect.html#o2">wRight</a> + 1, rect.<a class="code" href="structFG__Rect.html#o3">wBottom</a> + 1);00243 00244 <span class="comment">// 删除绘图资源</span>00245 SelectObject(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, hPenOld);00246 DeleteObject(hPen);00247 SelectObject(<a class="code" href="classFG__Win32DrawInterface.html#p1">m_hMemDC</a>, hBrushOld);00248 }00249 }00250 </pre></div><hr><center>由 DoxyGen 1.3.6 于 Wed Jun 9 22:34:41 2004 生成<br>版权所有 (C) 2003,2004 王咏武</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -