|
BlackDogEngineering wrote:
BUT: is there a _better_ way?
I think you have no choice but to format the number as a string and display that. Why not link a CString to the edit control?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
The only improvement is to use "%#04x" to automagically add the 0x prefix.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Can anybody tell me why I am getting this error for the following line:
graphics = new Graphics(hdcPrint);
For your information, this is my function:
// this function is for OTCDialog: OK button
// It uses GDI to send image to a printer
void OTRDialog::OnPrintFrom()
{
DWORD size;
HDC hdcPrint;
DOCINFO docInfo;
ZeroMemory(&docInfo, sizeof(DOCINFO));
docInfo.cbSize = sizeof(DOCINFO);
docInfo.lpszDocName = "GdiplusPrint";
// Create a PRINTDLG structure, and initialize the appropriate fields.
PRINTDLG printDlg;
ZeroMemory(&printDlg, sizeof(PRINTDLG));
printDlg.lStructSize = sizeof(PRINTDLG);
printDlg.Flags = PD_RETURNDC;
// Display a print dialog box.
if(!PrintDlg(&printDlg))
{
printf("Failure\n");
}
else
{
// Now that PrintDlg has returned, a device context handle
// for the chosen printer is in printDlg->hDC.
StartDoc(hdcPrint, &docInfo);
Graphics* graphics;
StartPage(hdcPrint);
graphics = new Graphics(hdcPrint);
Image image(L"My_report.bmp");
graphics.DrawImage(&image, 5, 0, 360, 410);
// Create a string.
WCHAR string[256];
wcscpy(string, L"Sample Text");
// Initialize arguments.
Font myFont(L"Arial", 6);
PointF origin(20.0f, 5.0f);
SolidBrush blackBrush(Color(255, 0, 0, 0));
// Draw string.
graphics.DrawString(string, wcslen(string), &myFont, origin, &blackBrush);
delete graphics;
EndPage(hdcPrint);
EndDoc(hdcPrint);
DeleteDC(hdcPrint);
}
if(printDlg.hDevMode)
GlobalFree(printDlg.hDevMode);
if(printDlg.hDevNames)
GlobalFree(printDlg.hDevNames);
if(printDlg.hDC)
DeleteDC(printDlg.hDC);
}
|
|
|
|
|
How many parameters does the constructor for Graphics take? Sounds like your giving it less than the number required.
|
|
|
|
|
It takes exactly what she is giving it - a HDC.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
DEBUG_NEW defines a new operator that takes three parameters to catch memory leaks when _DEBUG is also defined. Redefine it to use the non-debug new.
Or, use the scope resolution operator ( :: ) before new to use the default C++ version.
|
|
|
|
|
1. Why does graphics have to be a pointer ? I seem to recall GDI+ does not like having new called on things in C++ ( new in C# is a totally different beast ), because it forces you to use it's .Clone methods instead.
2. Once you fix this, you'll get errors because you're using the . instead of the -> for the graphics object ( as it's a pointer ).
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Try this:
graphics = ::new Graphics(hdcPrint);
The problem is that an MFC generated define, DEBUG_NEW, defines a "new" operator that takes three parameters. It only applies for a debug build; if you do a release build your program should work. You can undefine DEBUG_NEW so that debug builds also work.
Or, as shown in the example code above, you can use the scope resolution operator ( :: ) before new to use the default C++ version.
|
|
|
|
|
It like that there is no the splash screen compoent in
VC++.Net.How can I add a splash screen to my VC++.net porject???
|
|
|
|
|
hi, is there any equivalent structure defined in C++ as that of timespec in Unix? the timespec definition is:
struct timespec {
long tv_sec; /* number of seconds */
long tv_nsec; /* number of nanoseconds */
};
I tried to search it in MSDN to no avail.
|
|
|
|
|
Check FILETIME struct. It's not the exact equivalent, but uses 100-nanosecond intervals.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
wow, this is fast. I fooled around in lounge for a while and when I was back, you have posted the answer. Salute!
|
|
|
|
|
If you look closely at the time displayed next to the subject, you'll see that I've actually answered your question before you've asked
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
wow, you are always one or two minutes ahead of me. Do you know how to read mind remotely?
|
|
|
|
|
OK, this seems like it should be very simple but I am stumped.
How can you tell an MFC menu to display itself?
I have the CMenu object but there doesn't appear to be a function for this.
SendMessage to the CDialog might be the way to go but I'm not sure what the message would be.
Michael Kramer
-=[mkramer@hamsoft.com]=-
|
|
|
|
|
If you are trying to create a Context Menu, then you should be able to use CMenu::TrackPopupMenu(...) .
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
(Try Check Favorites Sometime!)
|
|
|
|
|
Hello everyone.
I have a question concerning how to drag
dialog boxes.
I currently have a dialog box that is completely
filled with a CWebBrowser2 ActiveX control. I
would like to be able drag the entire dialog box
when a user does a "mousedown and drag" within
the browser control.
Can anyone please help me out with this?
Thanks.
|
|
|
|
|
pseudo-code:
1-trap mouse-down message, and save current mouse position
2-trap mouse-move message, and if mouse is down, compute new window position based on current position and original position
3- move the window.
Max.
|
|
|
|
|
Nononono.
Kids, kids, haven't had to learn Windows programming the hard way...
You trap the WM_NCHITTEST message, and if it's in the area you want to act as the caption (which is where you usually click to drag the window) you respond HT_CAPTION, else you call DefWindowProc (or equivalent).
|
|
|
|
|
I need some help with Ini files as I am going to parse them in my application .
I have the following questions:
1. THis file is not going to be placed in the Windows directory . How should i Access it using the GetProfileString method ?
2. This File is a bit different . tags [] are going to be placed as
[main]
detail1=0
detail2=1
detail3=1
[detail1]
param_a=val1
param_b=val2
param_c=val3
[detail3]
.
.
Which is the best method to extract these details ?
|
|
|
|
|
Use GetPrivateProfile...() instead of GetProfile...() . You should have no problems with the format.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Use GetPrivateProfileXXX functions to access .ini files located anywhere. GetProfileXXX family of functions works only with win.ini.
act_x wrote:
2. This File is a bit different . tags [] are going to be placed as
SO where's the difference? Square brackets are used to mark sections. Are you going to use them in other context?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
I am a student trying hard to learn the language and seem to be doing pretty well....for the most part. I have a small project I have been working on the past 2 weeks and am really stuck. If someone could possibly lend me some guidence I'd REALLY appreciate it.
My project has to include a FlexGrid Control with 7 Rows (one fixed) and 7 columns (one fixed). I've got this done and all the labels set. I have created my array, and used a switch statement to populate the fields that aren't fixed. For some reason that data seems to be entering into my FlexGrid purely at random. I've done all I can possibly think of and it isn't making any sense to me why this is happening.
Could someone please help me get pointed in the right direction?
Thank you for your time,
Garry
|
|
|
|
|
how do you populate fields in your Grid ?
Id use
grid.SetRow(desired_row);
grid.SetCol(desired_col);
grid.SetText(value);
|
|
|
|
|
I have a Child Frame that I need to minimize and maximize but not destroy . i.e I dont want the Frame to be destroyed when one clicks on the "X" button on the top. Please help
|
|
|
|