| | |
Win32 Resource Problem
![]() |
I have the following script of a dialog box:
The dialog box itself works great, the problem is that it's not propely sized. As in the script, I want it 500 by 300 pixels, but for a reason I can't figure out, it's much bigger than that (it has around 800 by 600 pixels). I think it's something related with the font, cause when I lower the font's point size to 6, the whole dialog box becomes smaller (still not 500 by 300), but all the controls shrink as well.
I've attached some images. The third image appears normal, but I had to change the width and size to 426 and 281 so it appears at 645 by 489.
Can someone please tell me what I did wrong ? Thanks in advance.
C++ Syntax (Toggle Plain Text)
#include "Resources.h" IDD_MAIN DIALOGEX 0,0,500,300 FONT 8,"Tahoma",400,0 STYLE WS_CAPTION|WS_VISIBLE|WS_SYSMENU|WS_GROUP|DS_CENTER EXSTYLE WS_EX_APPWINDOW BEGIN // controls END
C++ Syntax (Toggle Plain Text)
... hDlgMain = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_MAIN), hWndMain, MainDlgProc, (LPARAM)&MyData); ...
I've attached some images. The third image appears normal, but I had to change the width and size to 426 and 281 so it appears at 645 by 489.
Can someone please tell me what I did wrong ? Thanks in advance.
Yes you are correct. The size of the dialog box depends on the size of the font.
Also read the section on "Dialog Box Measurements" from this MSDN page. It explains on how to convert between dialog box measurements and pixels.
•
•
•
•
Originally Posted by Charles Petzold, Programming Windows-5th Edition, page 489-490
The dialog box that I designed has a template that looks like this:
The first line gives the dialog box a name (in this case, ABOUTBOX). As is the case for other resources, you can use a number instead. The name is followed by the keywords DIALOG and DISCARDABLE, and four numbers. The first two numbers are the x and y coordinates of the upper left corner of the dialog box, relative to the client area of its parent when the dialog box is invoked by the program. The second two numbers are the width and height of the dialog box.C++ Syntax (Toggle Plain Text)
ABOUTBOX DIALOG DISCARDABLE 32, 32, 180, 100 STYLE DS_MODALFRAME | WS_POPUP FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK",IDOK,66,80,50,14 ICON "ABOUT1",IDC_STATIC,7,7,21,20 CTEXT "About1",IDC_STATIC,40,12,100,8 CTEXT "About Box Demo Program",IDC_STATIC,7,40,166,8 CTEXT "(c) Charles Petzold, 1998",IDC_STATIC,7,52,166,8 END
These coordinates and sizes are not in units of pixels. They are instead based on a special coordinate system used only for dialog box templates. The numbers are based on the size of the font used for the dialog box (in this case, an 8-point MS Sans Serif font): x-coordinates and width are expressed in units of 1/4 of an average character width; y-coordinates and height are expressed in units of 1/8 of the character height. Thus, for this particular dialog box, the upper left corner of the dialog box is 5 characters from the left edge of the main window's client area and 2-1/2 characters from the top edge. The dialog itself is 40 characters wide and 10 characters high. This coordinate system allows you to use coordinates and sizes that will retain the general dimensions and look of the dialog box regardless of the resolution of the video display and the font you've selected. Because font characters are often approximately twice as high as they are wide, the dimensions on both the x-axis and the y-axis are nearly the same.
Last edited by WolfPack; Nov 7th, 2006 at 10:43 pm.
バルサミコ酢やっぱいらへんで
•
•
Join Date: Nov 2006
Posts: 7
Reputation:
Solved Threads: 0
Hi this is Shiva..
I saw the snap shots of your application..
Can i have the piece of code to create the tabcontrol(and adding button,labrls to it) and datagrid..
Now i am developing Sample Library management Project using Win32 using Dev c++ compiler..
I really need of Datagrid to display book details and also need Tab control ..
Please send me the way to do this ..please send some simple tutorials..
Thanks in advance..
I saw the snap shots of your application..
Can i have the piece of code to create the tabcontrol(and adding button,labrls to it) and datagrid..
Now i am developing Sample Library management Project using Win32 using Dev c++ compiler..
I really need of Datagrid to display book details and also need Tab control ..
Please send me the way to do this ..please send some simple tutorials..
Thanks in advance..
@Wolfpack: Thanks. I coincidentally happen to read Charles Petzold's book, but I'm only at page 273 :cheesy:.
@Shiva_nan: I'm a beginner in Windows programming, so I don't think I can help you very much. I'll post the code I used to create the listview and tab controls you see in the screenshots, but I don't know how to work with them yet.
@Shiva_nan: I'm a beginner in Windows programming, so I don't think I can help you very much. I'll post the code I used to create the listview and tab controls you see in the screenshots, but I don't know how to work with them yet.
C++ Syntax (Toggle Plain Text)
// Resources.rc CONTROL "",IDC_TAB,"SysTabControl32",WS_CHILD|WS_VISIBLE|WS_TABSTOP|TCS_FOCUSNEVER,233,53,189,208 CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT|WS_CHILD|WS_VISIBLE|WS_TABSTOP|LVS_SINGLESEL,4,68,224,208,WS_EX_CLIENTEDGE // Main.cpp (dialog box's WndProc) LPTSTR column[] = {"First Name", "Last Name", "Nickname"}; HWND List = GetDlgItem(hWnd, IDC_LIST); LVCOLUMN lvc; lvc.mask = LVCF_WIDTH | LVCF_TEXT; lvc.cx = 110; for(unsigned int i = 0; i < sizeof(column) / sizeof(column[0]); i++) { lvc.pszText = column[i]; ListView_InsertColumn(List, i, (LPARAM)&lvc); } LPTSTR tab[] = {"Basic", "Home Address", "Work Address"}; HWND wtab = GetDlgItem(hWnd, IDC_TAB); TCITEM tci; tci.mask = TCIF_TEXT; for(unsigned int i = 0; i < sizeof(tab)/sizeof(tab[0]); i++) { tci.pszText = tab[i]; TabCtrl_InsertItem(wtab, i, &tci); }
•
•
•
•
Hi this is Shiva..
I saw the snap shots of your application..
Can i have the piece of code to create the tabcontrol(and adding button,labrls to it) and datagrid..
Now i am developing Sample Library management Project using Win32 using Dev c++ compiler..
I really need of Datagrid to display book details and also need Tab control ..
Please send me the way to do this ..please send some simple tutorials..
Thanks in advance..
Last edited by Ancient Dragon; Nov 8th, 2006 at 11:38 am.
The most important thing in the Olympic Games is not to win but to take part, just as the most important thing in life is not the triumph but the struggle. The essential thing is not to have conquered but to have fought well.
-Pierre de Coubertin, The Olympic Creed Inspired by Bishop Ethelbert
-Pierre de Coubertin, The Olympic Creed Inspired by Bishop Ethelbert
![]() |
Similar Threads
- Generic Host Process for Win32 Error (Viruses, Spyware and other Nasties)
- Not a valid Win32 application - problem (Viruses, Spyware and other Nasties)
- Another Trojan:Win32/Virtumonde.O problem? (Viruses, Spyware and other Nasties)
- Generic Host Process for Win32 Error (Viruses, Spyware and other Nasties)
- resource problem code 12 (Troubleshooting Dead Machines)
Other Threads in the C++ Forum
- Previous Thread: savefiledialog in a dialog window
- Next Thread: Collision Detection
Views: 3352 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C++
algorithm api array arrays assignment basic beginner binary browser c++ c/c++ calculator char class classes code compile compiler constructor conversion convert count data delete desktop display dll dynamic encryption error file files form fstream function functions game givemetehcodez graph gui homework i/o iamthwee input int integer lazy library linker list loop loops map math matrix member memory network newbie news number object objects opengl output parameter pointer pointers problem program programming project random read recursion recursive reference sort sorting spoonfeeding string strings struct student studio template templates text time tree undefined variable vc++ vector video visual win32 window windows winsock






