WM5 development C++ - set up GUI
-
I'm new to WM development, but I know C (mostly embedded, but also LabWindows/CVI). (I think I'm developing in MFC -- not exactly sure how that works even thought Joel gave me a good description in another forum.) So, I'm all good with the straight C type stuff, I've opened and read a file, save the data from it in an array. The problem I'm having is finding something to help get me going in a direction to display the data on the screen. What I'd ultimately like to do is have a check box for each line and then two more columns of text from the file (two words, one for each column), sort of like a table. Like this: Check Box First Second x this that x some something I have searched MSDN, but I can't find anything that is straight forward (like CreateWindow(), CreateTable(), and FillCell()). I've searched for a C++ sample, but nothing seems to spring out that is doing anything like this that I can find, everything I've found is displaying pictures, or is in C# or using Classes (which seems too complicated for what I am trying to do). Any hints as to what I can look at to get going in the right direction, or some sample code that I can experiment, or even some functions I can search MSDN for would be greatly appreciated. Thanks
-
I'm new to WM development, but I know C (mostly embedded, but also LabWindows/CVI). (I think I'm developing in MFC -- not exactly sure how that works even thought Joel gave me a good description in another forum.) So, I'm all good with the straight C type stuff, I've opened and read a file, save the data from it in an array. The problem I'm having is finding something to help get me going in a direction to display the data on the screen. What I'd ultimately like to do is have a check box for each line and then two more columns of text from the file (two words, one for each column), sort of like a table. Like this: Check Box First Second x this that x some something I have searched MSDN, but I can't find anything that is straight forward (like CreateWindow(), CreateTable(), and FillCell()). I've searched for a C++ sample, but nothing seems to spring out that is doing anything like this that I can find, everything I've found is displaying pictures, or is in C# or using Classes (which seems too complicated for what I am trying to do). Any hints as to what I can look at to get going in the right direction, or some sample code that I can experiment, or even some functions I can search MSDN for would be greatly appreciated. Thanks
I keep thinking what you are describing is best served by a ListView in detail mode with a checkbox, but I can't find my MFC reference to verify this. But I am sending this message just so that you know I will look into this question.
Joel Ivory Johnson
Meet my dev team: RDA Architecture Evangelist Team Blog
My site: J2i.net
Twitter: J2iNet
-
I keep thinking what you are describing is best served by a ListView in detail mode with a checkbox, but I can't find my MFC reference to verify this. But I am sending this message just so that you know I will look into this question.
Joel Ivory Johnson
Meet my dev team: RDA Architecture Evangelist Team Blog
My site: J2i.net
Twitter: J2iNet
I found an example that I'm trying to use for a reference, but it is doing stuff with pictures, and I just want to display text. It is using the following functions: BeginPaint() LoadString() SHLoadImageResource() CreateFontIndirect() GetClientRect() DrawText() GetClientRect() DrawText() EndPaint() There is a little more, but I think this is the gist of writing to the screen. In tinkering with this example, I keep breaking it trying to figure out which parts are the parts that write just the text; while not displaying the image. The code I'm using (I can't remember where I found it, it might have been here, but I can't find it again) displays a picture with a text caption under it. I'm trying to see how the text part works byt removing the image part, so it just displays the caption. When I do it, I get the caption with the first picture, but not the second picture. The screen is just blank.
-
I found an example that I'm trying to use for a reference, but it is doing stuff with pictures, and I just want to display text. It is using the following functions: BeginPaint() LoadString() SHLoadImageResource() CreateFontIndirect() GetClientRect() DrawText() GetClientRect() DrawText() EndPaint() There is a little more, but I think this is the gist of writing to the screen. In tinkering with this example, I keep breaking it trying to figure out which parts are the parts that write just the text; while not displaying the image. The code I'm using (I can't remember where I found it, it might have been here, but I can't find it again) displays a picture with a text caption under it. I'm trying to see how the text part works byt removing the image part, so it just displays the caption. When I do it, I get the caption with the first picture, but not the second picture. The screen is just blank.
FYI: OK, I got through this, and I am drawing rectangles and filling with text
fbrush = CreateSolidBrush(bcol);
FillRect(ps.hdc, &rect, fbrush);
wsprintf(szLabel, TEXT("Remove"));
rect.top += 2;
rect.left += 2;
DrawText(ps.hdc, szLabel, -1, &rect, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE);This is creating a rectangle on the screen, filling it with a specified color, and writing the text "Remove" in the rectangle. The problem I was having was the code I was refering to had an image that it was displaying with text under it. I had problems figuring out what was the image part and what was the text part. I basically just looked at the functions, and read about them at MSDN, and created what I have above. The one thing I can't figure out is the background color for the text. The rectangles I'm using are filled with a background color, but the text background fills with white. I have not been able to find where to change that, there does not seem to be an option for DrawText. Anyone know?
-
FYI: OK, I got through this, and I am drawing rectangles and filling with text
fbrush = CreateSolidBrush(bcol);
FillRect(ps.hdc, &rect, fbrush);
wsprintf(szLabel, TEXT("Remove"));
rect.top += 2;
rect.left += 2;
DrawText(ps.hdc, szLabel, -1, &rect, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE);This is creating a rectangle on the screen, filling it with a specified color, and writing the text "Remove" in the rectangle. The problem I was having was the code I was refering to had an image that it was displaying with text under it. I had problems figuring out what was the image part and what was the text part. I basically just looked at the functions, and read about them at MSDN, and created what I have above. The one thing I can't figure out is the background color for the text. The rectangles I'm using are filled with a background color, but the text background fills with white. I have not been able to find where to change that, there does not seem to be an option for DrawText. Anyone know?