473,322 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

drawing an onscreen grid

hi

im doing some stuff in visula c++ 2008

Im hoping someone can direct me to an algorithm to draw an onscreen
grid that has equal squares like a testpattern regardless of the
current resolution

I can get the curren screen res
I can draw a grid ok to

but i cant work out how to draw a neat grid with all the squares equal
size, all fitting neatly onscreen with no cut offs. the squares dont
have to be any specific size (other than i want to have 2
testpatterns, on with "large" squares and one with "small squares")
but they all need to be equal with no cutoffs

and it has to be calculated in any screen resolution a user may
select.

any advice appreciated

thanks

Peted
Feb 6 '08 #1
1 1402

<Petedwrote in message news:5m********************************@4ax.com...
hi

im doing some stuff in visula c++ 2008

Im hoping someone can direct me to an algorithm to draw an onscreen
grid that has equal squares like a testpattern regardless of the
current resolution

I can get the curren screen res
I can draw a grid ok to

but i cant work out how to draw a neat grid with all the squares equal
size, all fitting neatly onscreen with no cut offs. the squares dont
have to be any specific size (other than i want to have 2
testpatterns, on with "large" squares and one with "small squares")
but they all need to be equal with no cutoffs

and it has to be calculated in any screen resolution a user may
select.
Take the screen resolution, divide by the number of squares you want?

Just about all screen resolutions are either 4:3 or 16:9 aspect ratio.

You might also use the modulo operator (%) to help you find a number that
the screen resolution components are evenly divisible by.

example:

for( squaresize = screenxres / 16; (screenxres % squaresize) || (screenyres
% squaresize); squaresize-- )
;

should give you
16x12 squares of 64 pixels each on 1024x768
16x12 squares of 50 pixels each on 800x600
16x12 squares of 100 pixels each on 1600x1200
20x16 squares of 64 pixels each on 1280x1024
18x12 squares of 80 pixels each on 1440x960

>
any advice appreciated

thanks

Peted

Feb 6 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Benoit Martin | last post by:
I had to draw my own control because I couldn't find any control doing what I wanted it to do. This control has a grid that I need to have control over. To do that, I draw each line of the grid...
1
by: Eric Sabine | last post by:
Has anybody seen any online examples of drawing on a form at runtime? In essence, this app plays video for a user. The user will be alle to choose from a line, pencil, etc (similar to what you...
1
by: Niels Jensen | last post by:
Hi guys, I have the following code which is supposed to draw a grid in a panel consisting of a specified number of squares. I can get it to draw the grid and activate the autoscroll feature,...
1
by: Sam | last post by:
Hi guys I'm writing a small drawing program which has "snap to grid" mode and I want to display something (some kind of shapes for example a small square or circle which indicate the current...
5
by: Steve Marshall | last post by:
Hi all, I am converting an app which used a picturebox to draw graphs etc onto, then saved them to a file. I can certainly draw things onto a picturbox in VB.NET, but how do I save them to a...
2
by: hans.duedal | last post by:
The Gecko DOM reference gave me the idea that an onscreen keyboard I was doing should use Key Events, so the user may for instance place a letter anywhere, and such. While this can be handled using...
1
by: Andrew | last post by:
Hello Everyone I am receiving an error in an application I am working on. The application when its done will be a Dungeons and Dragons Network game. I am having problems with the Networked...
6
by: James Hahn | last post by:
That looks like proper Property set code to me. What is the line of code that the designer is generating in the Sub InitializeComponent for a color that you select in the Properties Settings? ...
2
by: Nathan Sokalski | last post by:
I am attempting to create icons for controls I have created using VB.NET by using the System.Drawing.ToolboxBitmap attribute. I have managed to do this in C# by specifying the path to the *.ico...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.