|
|
#1 |
|
Rookie
Join Date: Jul 2009
Posts: 15
![]() |
Windows Programming Question
Hi,
I'm trying to make a new windows application and learn windows programming because my lack of knowledge in that area is preventing me from actually doing anything significant. All the functions in z-term.c seem to be used for writing text to the screen. I was wondering if someone could point me to the "bottom" level function that actually does the job of writing a character to the screen. That is, how one would do it if they were starting an application from scratch in MSVC++ 2008 Express Edition. Thanks for any help. Cheers, Kyle |
|
|
|
|
|
#2 |
|
Knight
Join Date: May 2009
Posts: 560
![]() |
In file main-win.c
Code:
2129 static errr Term_text_win(int x, int y, int n, byte a, cptr s)
2130 {
2131 term_data *td = (term_data*)(Term->data);
2132 RECT rc;
2133 HDC hdc;
2134
2135
2136 /* Total rectangle */
2137 rc.left = x * td->tile_wid + td->size_ow1;
2138 rc.right = rc.left + n * td->tile_wid;
2139 rc.top = y * td->tile_hgt + td->size_oh1;
2140 rc.bottom = rc.top + td->tile_hgt;
2141
2142 /* Acquire DC */
2143 hdc = GetDC(td->w);
2144
2145 /* Background color */
2146 SetBkColor(hdc, RGB(0, 0, 0));
2147
2148 /* Foreground color */
2149 if (colors16)
2150 {
2151 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
2152 }
2153 else if (paletted)
2154 {
2155 SetTextColor(hdc, win_clr[a & (BASIC_COLORS-1)]);
2156 }
2157 else
2158 {
2159 SetTextColor(hdc, win_clr[a]);
2160 }
2161
2162 /* Use the font */
2163 SelectObject(hdc, td->font_id);
2164
2165 /* Bizarre size */
2166 if (td->bizarre ||
2167 (td->tile_hgt != td->font_hgt) ||
2168 (td->tile_wid != td->font_wid))
2169 {
2170 int i;
2171
2172 /* Erase complete rectangle */
2173 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2174
2175 /* New rectangle */
2176 rc.left += ((td->tile_wid - td->font_wid) / 2);
2177 rc.right = rc.left + td->font_wid;
2178 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
2179 rc.bottom = rc.top + td->font_hgt;
2180
2181 /* Dump each character */
2182 for (i = 0; i < n; i++)
2183 {
2184 /* Dump the text */
2185 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
2186 s+i, 1, NULL);
2187
2188 /* Advance */
2189 rc.left += td->tile_wid;
2190 rc.right += td->tile_wid;
2191 }
2192 }
2193
2194 /* Normal size */
2195 else
2196 {
2197 /* Dump the text */
2198 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
2199 s, n, NULL);
2200 }
2201
2202 /* Release DC */
2203 ReleaseDC(td->w, hdc);
2204
2205 /* Success */
2206 return 0;
2207 }
2199 s, n, NULL); The exact function is ExtTextOut(HDC, x, y, FLAGS, RECT area, string pointer, number of characters, NULL) I can't remember what the last parameter is, but I've never used anything but null. Make sure to get the window's HDC and set the text color, etc. |
|
|
|
|
|
#3 |
|
Rookie
Join Date: Jul 2009
Posts: 15
![]() |
Awesome! Thanks! That's exactly what I was looking for.
|
|
|
|
|
|
#4 |
|
Knight
Join Date: May 2009
Posts: 560
![]() |
|
|
|
|
|
|
#5 | |
|
Angband maintainer
Join Date: Apr 2007
Posts: 1,382
Donated: $40
![]() |
Quote:
__________________
I'm still not adding it as an option... |
|
|
|
|
|
|
#6 |
|
Knight
Join Date: May 2009
Posts: 560
![]() |
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with Windows 7 ? | JohanVikman | Vanilla | 5 | July 11, 2009 19:15 |
| Morgothian programming language | zaimoni | Idle chatter | 2 | April 22, 2009 09:26 |
| Term windows | Aristobulus | Variants | 9 | November 6, 2008 14:43 |
| I've downloaded 3.0.9b for Windows... now what? | PowerWyrm | Vanilla | 5 | October 14, 2008 02:24 |
| Windows v3.0.9 hanging? | JustinH | Vanilla | 1 | August 27, 2008 14:30 |