How to draw 2D values to windows screen??

Suppose now I have a 2D array containing binary values only (1 or 0). I would 
like to draw these values on the windows screen (created by MFC dialog-based 
app in MSVC++ 2005) with 0 be black (0, 0, 0) and 1 be white (255, 255, 255). 
Which MFC class and function should I use to achieve this effect??
Question (23)
3/27/2007 11:58:59 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 15

Newbie Question wrote:
> Suppose now I have a 2D array containing binary values only (1 or 0). I would 
> like to draw these values on the windows screen (created by MFC dialog-based 
> app in MSVC++ 2005) with 0 be black (0, 0, 0) and 1 be white (255, 255, 255). 
> Which MFC class and function should I use to achieve this effect??

Put a static control (also called Picture control) on the dialog. 
Subclass it with a class you derive from CStatic.  Add a WM_PAINT 
message handler in your class.

In your class OnPaint you can paint anything you want on that static 
control.  For example, you  could use SetPixel to set colors to black or 
white.  After you get that much working you may want something more 
sophisticated, as SetPixel is quite slow.  The more sophisticated, 
higher performance approach would be to draw to an in-memory bitmap and 
blit it to the screen.

Scott McPhillips [VC++ MVP]

3/28/2007 12:24:55 AM

Similar Artilces:

Display 2D Lines for mathematic application
Hi There, Does anyone can give me advices to choose a graphical library/control/ocx/other to developp an application displaying 2d lines from large data set (around 30 000 points). I have to developp this app using Visual C++(6 or .NET). These data are coming right from an electronic device, and I need to display and print result as graphs in a short amount of time (less than 8 hours :o) ) Of course, it's a common subject, but I'm not aware of last improvement about graphical resources, so I'm stumped !! I'm reading doc about GDI, but it seems to be too slow for this kind of ...

Authentication against a windows 2003 server
Hej I'm using a network with a linux dhcp and dns server. I need to implement authentication through Active Directory on a web site. I have installed a windows 2003 server, and made the web application authenticate against users in the servers Active Directory. It all works perfectly. Now I need to test NTLM (single sign on), ie. you log in on a windows client (Windows Vista in this case), and you should then be logged in on the web site without entering your username and password when you open the browser. Therefore I need to authenticate vista against the windows 2003 ser...

ADO & Scrolling Window
I am trying to show the Project Budgted Qty while user is entering an item in PA Purchase Order Entry scrolling windows. I delcared the ADO object in PurchaseOrderEntryDetail(Grid) but where should I closed and release the ADO connection? for other windows, I put my code in Window_BeforeClose. thks I usually create the connection on the main window open and close it on window close. I make a property on the main window to expose the connection and then access it instead of a connection on the details window. If you open and close the connection on each line, you can run into ADO ...

percenatge increase in values across multiple cells
Hi I have a spreadsheet of numerical values and I simply want to increase all values, in all cells, by 17.5%. Can anyone please tell me how to do this? Many thanks David David Type 1.175 in a spare cell and copy it... Highlight your numbers and then edit>paste special...>values+multiply -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England "David" <> wrote in message > Hi > > I have a spreadsheet of numerical values and I simp...

How to have value scales on x and y axes?
I cannot find how to do a simple graph of y versus x where I can set the scale of both the x axis and the y axis. In my attempts, it appears that only one axis eg the y axis can have actual "values" shown on the axis. Although the data is graphed as the y values versus the x values, the scale cannot be set on the x axis as it is a "category" axis - so that the labels along the x axis are for example "1", "2", "3"....where this means "Point 1", "Point 2", "Point 3".....though the actual values of those poin...

I just had an excel upgrade and can't find the way to add arrows to a cell. I old excel the result was to up and down arrows, at the side of the cell, which would allow the user to click up or down to change the cell value... Insert a Spin Button from Forms Toolbar or Control Toolbox. Assuming upgrade means 2007 version....... Click on Developer Tab and in Controls category Insert>Form Controls. Select the spin button and place it where you want. Right-click and Format Control. Pick a cell to link. If you don't see Developer Tab on Ribben go to Button>Ex...

a new drawing not erase previous drawing?
visual studio c++ 6.0, mfc, graphics in my program a new drawing erases previous drawing. How to manage that all that is drawn stays alive on the window? And is not erased when the window is covered by another window, as well. And that the image does not flicker... Those last two have from time to time appeared in my attempts to solve the first problem. And that I didn't manage at all - make the first drawing, then the second, see them both at the same time on the window. I have tried the following and maybe more: Invalidate(false), InvalidateRect(false), override OnEraseBkgnd, ...

Need null values for several fields in db
I have an equipment inventory db. I need to run a query that would give me the records that contain null values in several of the fields. I have run a successful query to return records that have a null value in one field but don't know how to combine so that query returns records that also have null values in other fields or any other fields. Please advise -- dmp You join the seperate queries with a UNION. SELECT * From YourTable WHERE YourField Is NULL UNION SELECT * From YourTable WHERE YourField2 Is NULL UNION SELECT * From YourTable WHERE YourField3 Is NUL...

Text values to numeric values
Is there a formula to convert a text value in a cell to a numeri value? Thanks, Jayveeja -- jayveeja ----------------------------------------------------------------------- jayveejay's Profile: View this thread: Good afternoon Jatveejay Yes there is. Say your numeric value is in A1, in B1 the formula: =VALUE(A1) will show the number as a value. If you wanted to convert a number in its cell from a text number to a value number, ie., not use a formula in a di...

Match values in more than one column
Hi I have three columns of data and wish to highlight the matches or change the format if there are any duplicates. i.e A B C Apple Banana Cheese Banana Orange Milk Chocolate Milk Water Biscuits Pear Bread Wafers Plum Banana So Banana would be highlighted in all, Milk in B and C. I assume I'd use conditional formatting, but the MATCH functio...

Copy and paste formula; Value pastes instead
Excel 2002 I've tried starting several worksheets, checking formats, pasting special (formula only). For some reason the formula actually copies OK by looking at the formula bar, but the value in the cell is identical to the value of the copied cell.Incorrect. Tried even the simplest formulas with no joy. BK ...

how to draw a bitmap transparently?
Hi, I have an owner draw button associated with a bitmap. In the bitmap editor, I turn off the option "draw opaque" for the bitmap. That is, I make it transparent. However, the the bitmap's background color still shows up on the button. The bitmap has only a solid circle in the middle. What else do I have to do? Please help. Thanks. Tony One thing you can do--and this works only for some restricted cases, which you may or may not have--is to make the button background 192,192,192, and when you LoadImage, you specify LR_MAP3DCOLORS. It will change the 192,192,192 to...

Conditional format
Hi Conditional format Is there a way to get a cell's format determined by the format of a different cell?! e.g. Could one get an entire row market up in say bold red if one cell in that row was say less than 100 With thanks Ship Shiperton Henethe Hi Shiperton yep ) select the rows that you want to apply the conditional formatting to, ensuring that the first row of this group is the first row at the top of the screen (it gets confused sometimes if it isn't) the following example assums you've selected from row 2 onwards and you want the row to turn red if ...

Triggers on Extender windows
Is it possible for writing a Trigger on any of the Extender windows which we create? I tried with one Extender screen, but the trigger fails to register, saying INVALID OBJECT. Any immediate response would be great. -- Thanks & Regards, Vaidhyanathan Mohan Hi Vaidy Extender uses multiple identical generic windows with multiple sets of generic fields of the various data types. You will not know which window is being used and what it is being used for, or what fields will be shown at any time. I am yet to see anyone successfully write a customisation (Dexterity or VBA) against ...

DATABASE pulling values from Spreadsheet
I know just enough to be dangerous. We have our business system set up to pull database queries out of the system, say for example, raw material part numbers, description and average cost or last cost as well as avg usage. I would like to set up an Access database to contain recipies (plastic blends for different applications) The current cost tool that sales has requires historical cost data from the system in order to cost products. Small runs tend to inflate cost information (lots of down time, poor yields) The database would have each ingredient, amount, cost and would look up th...

reference to lookup value
I'm trying to write an expression that refers to a value in a combobox on a form that is derived from a lookup field on a table that (of course) refers to values on another table. How can I properly reference this? Messing around with the bound column properties for the combo box and the underlying table has not helped. The only values I can get passed through to the VBA editor are the index value and null.-- Why are you asking me? I dont know what Im doing!Jaybird "Jaybird" <> wrote in message news:0D3D41C1-3C87-471F-983E-E2285D61E8CA...

Value axis
in my worksheet the data format 100% (no decimals) and in the value axis it shows as 100000000000% - how can I change this to show as a max of 3 digits. Thank you This makes little sense, all those zeros. What is the actual value in the sheet, and what is the actual number format in the sheet? - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - _______ "Shevvie" <> wrote in message > in my work...

Auto-exclusion of data labels for zero values
Hi guys, xl97 question. Is there a way to have data labels enabled** for all points plotted but with the labels automatically *excluded* for any zero values ? The exclusion is desired for aesthetic reasons. **e.g.: via Data Labels > Show value in say, Format Data Series dialog I find that these "zero" values showing on say, a column chart, have to be individually selected and removed on each series in a chart, a pretty tedious task. The values plotted are derived through formula and there would always be a couple of points here and there evaluating to zero values from time-to...

constant values
I have a very simple question, which I am not able to resolve though. I have created a query, which combines records from two tables. Works nicely. Now I would need to add several columns with either a) fix values, which will never change b) values which apply for all records, but which I would like to enter within a form every time I would like to run the query. The background is that I will use access as a mapping tool, so an original file will be uploaded and result in a table with the same name always. The query now takes the mappings for another table and combines the ...

Can't get Windows XP SP3 to recognise my Canon SX120 IS digital ca
I can't get my Windows XP SP3 PC to recognise my Canon SX120 IS digital camera via the USB port. My PC recognises other devices via the same USB port. The camera is recognised by other Windows XP SP3 PC's using the same USB cable. Any ideas, anybody? Julia Hopkins wrote: > I can't get my Windows XP SP3 PC to recognise my Canon SX120 IS digital > camera via the USB port. My PC recognises other devices via the same USB > port. The camera is recognised by other Windows XP SP3 PC's using the same > USB cable. Any ideas, anybody? Page 139 of the m...

owner draw CListBox, how to draw "no item found"
Hello, I have an owner draw listbox, in the DrawItem I draw the items. If the listbox doesn't contain any item I would like to display a message "no item found" but this is no item, so DrawItem is the wrong place. Where should I do this? OnPaint, OnEraseBkgnd? I thought I would be able to do something like this for a test (just paint the window blue) but it's always white BOOL CmyListbox::OnEraseBkgnd(CDC* pDC) { if (m_pItemList.GetCount() < 1) { CRect rc; GetClientRect(&rc); pDC->FillSolidRect(rc,RGB(0,0,255)); return TRU...

If column A = B then pick up value in D.
Hi I have a problem. I have two columns in different spreadsheets: A B D 27238-2807 27736-1321 D1 27736-1321 27238-2807 D2 27736-1321 27736-1321 D3 27736-1321 27736-1321 D8 27251-3761 27238-2807 D1 I would like to write a formula or VBA the if A = B then pick up the value in column D. Could you please help? Many thanks, Peter. Try the below in any c...

Selecting values in rows
I have the following problem: I have a lot of sheets with measurements on different dates and times dates and times in different columns. The problem is that not all tim series are the same, some measurement are every 30 minutes and som every hour. so some are like 01:00, 02:00, 03:00, etc and others ar 00:30, 01:00, 01:30 etc. All i want to do for now is: I want to create 1 main sheet with the following content 2 columns with dates and times (smallest time step of course) a lot of columns with the measurement.. so excel would have to do: Look in main sheet what time and date are asked for...

FWD: Look at critical pack for Windows
--nmbbnxcypcfq Content-Type: multipart/related; boundary="itifrvryovj"; type="multipart/alternative" --itifrvryovj Content-Type: multipart/alternative; boundary="farpnhppba" --farpnhppba Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Microsoft Customer this is the latest version of security update, the "October 2003, Cumulative Patch" update which eliminates all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Install now to prote...

converts screen units to the specified dialog box units
Hello, is it possible to converts screen units(pixel) to specified dialog box units? I can't search opposite function to MapDialogRect. I am using DLGTEMPLATE structure for creating dialogs. But this dialog is modified runtime and I would like to save it to file again to using in DLGTEMPLATE in next time. But I get coordinates by function GetWindowRect and this coordiantes are not useful for using in DLGTEMPLATE. Could you advide to me? Thank you Buly >is it possible to converts screen units(pixel) to specified dialog box >units? I can't search opposite function to MapDial...