Angband.oook.cz
Angband.oook.cz
AboutDownloadVariantsLadderForumCompetitionSpoilersComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old July 28, 2009, 20:55   #1
Kyle
Rookie
 
Kyle's Avatar
 
Join Date: Jul 2009
Posts: 15
Kyle is on a distinguished road
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
Kyle is offline   Reply With Quote
Old July 28, 2009, 21:02   #2
Sirridan
Knight
 
Sirridan's Avatar
 
Join Date: May 2009
Posts: 560
Sirridan is on a distinguished road
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	}
2198 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
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.
Sirridan is offline   Reply With Quote
Old July 28, 2009, 21:20   #3
Kyle
Rookie
 
Kyle's Avatar
 
Join Date: Jul 2009
Posts: 15
Kyle is on a distinguished road
Awesome! Thanks! That's exactly what I was looking for.
Kyle is offline   Reply With Quote
Old July 28, 2009, 23:38   #4
Sirridan
Knight
 
Sirridan's Avatar
 
Join Date: May 2009
Posts: 560
Sirridan is on a distinguished road
Quote:
Originally Posted by Kyle View Post
Awesome! Thanks! That's exactly what I was looking for.
NP, the lower level windows stuff is all in win-main.c I believe, or at least 99% of it.
Sirridan is offline   Reply With Quote
Old July 28, 2009, 23:40   #5
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,590
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by Sirridan View Post
NP, the lower level windows stuff is all in win-main.c I believe, or at least 99% of it.
*All* Windows stuff is in main-win.c.
__________________
"Physician, heal thyself."
takkaria is offline   Reply With Quote
Old July 29, 2009, 03:52   #6
Sirridan
Knight
 
Sirridan's Avatar
 
Join Date: May 2009
Posts: 560
Sirridan is on a distinguished road
Quote:
Originally Posted by takkaria View Post
*All* Windows stuff is in main-win.c.
Except for trunk/src/win... which really doesn't count though :P

Slowly but surely angband source is making sense to me, figuring it out has been a fun distraction when work has been slow.
Sirridan is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT +1. The time now is 13:07.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.