|
Hi...I'm developing a graphical interface. The programs computes some values that are later shown in control boxes in the screen. The program does already that, but I was wondering if there is any way to format that output. That is if the program is displaying in a control box a numeric variable it shows 99.9999 and not 99.999999 (or whatever).
I'm using MFC to do most of the stuff, like showing and reading, and all the computations are mine. In the part where the values are shown, I'm calling UPDATE() with false, so to not read values, just show the values.
Thanks,
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
Formatin output can be easily done when using CString::Format or sprintf. When searching MSDN for the latter one, you'll find appropriate documentation on how to set the precision of your output.
|
|
|
|
|
You can use
std::stringstream ss;
ss << std::setprecision(4) << YourVariable
m_Editbox.SetWindowText( ss.str().c_str() ); You can look up the other modifiers beside std::setprecision() in the Help. There is one for any need.
Or you simply use the old-fashioned way, from the days before C++ :
sprintf() or its wrapper in the CString class, Format() .
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hi,
I've placed this code on the OnInitialUpdate
if(m_pdcMemory->GetSafeHdc() == NULL)
{
CClientDC dc(this);
OnPrepareDC(&dc);
m_pdcMemory->CreateCompatibleDC(&dc);
}
and on the OnPaint handler the following code.
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
OnPrepareDC(&dc);
CRect rectUpdate;
dc.GetClipBox(rectUpdate);
m_pdcMemory->SelectClipRgn(NULL);
m_pdcMemory->IntersectClipRect(&rectUpdate);
CBrush backgroundBrush(::GetSysColor(COLOR_WINDOW));
CBrush* pOldBrush = m_pdcMemory->SelectObject(&backgroundBrush);
m_pdcMemory->PatBlt(rectUpdate.left, rectUpdate.top, rectUpdate.Width(), rectUpdate.Height(),
PATCOPY);
OnDraw(m_pdcMemory);
dc.BitBlt(rectUpdate.left, rectUpdate.top, rectUpdate.Width(), rectUpdate.Height(),
m_pdcMemory, 0, 0, SRCCOPY);
m_pdcMemory->SelectObject(pOldBrush);
In the OnDraw I've included code to draw some stuff. but I'm unable to get any output any idea what the cause could be
|
|
|
|
|
Hello!
It's hard to tell without having the rest of the code. But I think you ought to set viewport / window origin. Because you use m_pdcMemory->IntersectClipRect(&rectUpdate); where rectUpdate is in dc coordinates.
You can comment this function to check it.
And if you use scrolling you must set viewport / window origin, otherwise you will always see only top / left part of your picture.
With regards,
Pavel Krupets
|
|
|
|
|
ThankQ for the suggestion I've removed the code
.......
//m_pdcMemory->SelectClipRgn(NULL);
//m_pdcMemory->IntersectClipRect(&rectUpdate);
........
But it still doesn't seem to work.
|
|
|
|
|
Hello.
Sorry I've just spotted an error. You have to create and select bitmap into your off screen DC. Because by default it has 1 by 1 pixel monochrome bitmap selected.
Example
HDC hDC = CreateCompatibleDC(hScreenDC);<br />
<br />
if (!hDC)<br />
return false;<br />
<br />
<br />
long nWidth = 0;<br />
long nHeight = 0;<br />
<br />
if (pszClient)<br />
{<br />
nWidth = pszClient->cx;<br />
nHeight = pszClient->cy;<br />
}<br />
else<br />
{<br />
nWidth = GetDeviceCaps(hScreenDC, HORZRES);<br />
nHeight = GetDeviceCaps(hScreenDC, VERTRES);<br />
}<br />
<br />
<br />
HBITMAP hBitmap = CreateCompatibleBitmap(hScreenDC, nWidth, nHeight);<br />
<br />
if (!hBitmap)<br />
{<br />
DeleteDC(hDC);<br />
return false;<br />
}<br />
<br />
<br />
m_hOldBitmap = SelectObject(m_hDC = hDC, m_hBitmap = hBitmap);<br />
<br />
return true;
With regards,
Pavel Krupets
|
|
|
|
|
ThanQ very much it's working now.
|
|
|
|
|
Hello!
Maybe someone knows books titles or papers / articles about multi-threaded software development. I mean structure development: where do I need to use synchronization or locking and where I don't need to use neither of them, and how to avoid interlocks.
Maybe there are some methods that can be used to simplify multi-threaded software development (building some diagrams or something).
I used to develop small applications with 2 threads and a few objects (that used simultaneously by different threads), but now I have to develop application with huge amount of objects managed by lots of threads. And it's hard to imagine and to envisage all possible communications and interactions.
With regards,
Pavel Krupets
|
|
|
|
|
I use the "advanced windows programming" from Jeffrey Richter and Microsoft press.
That book has a lot of examples, explanations... related to multithreading.
Hope this helps...
|
|
|
|
|
How can we call a "SDI canvas form" from a dialog box ??
ie. if we select a SDI project and we want to invoke some dialog boxes and then SDI canvas form
How to proceed ??
|
|
|
|
|
Well, I'm not really sure what you want to do ...
but
How can we call a "SDI canvas form" from a dialog box ??
sounds like you've a dialog box and from there want to open a document. If yes, this could be done by calling OpenDocumentFile from you CSingleDocTemplate that's used to handle your documents.
If you rather want to display dialogs when a document gets opened, you can implement OnOpenDocument/OnNewDocument of your CDocument derived class and invoke your dialogs.
|
|
|
|
|
I Have Visual C++ .NET Standard (version 2002, Spanish), if i create a new project (based on CView, with Print and Print Preview support), or import old VC6 projects, when i activate the print preview and then zoom in, everything seems to go OK, but if i push the 'Next Page' button, the preview moves to the left, and if you scroll down the preview, the part of the preview that appears, do it centered, so the preview is shown broken. Does anybody notice this bug or occurs only in my version of MFC 7.0 ?, Any solution?. Thanks in advance.
|
|
|
|
|
:-OI developed form on SDI canvas. Suddenly I remembered to add a dialog box before that. i.e
I need a dialog box(sort of password screen) and then that SDI form shall appear. Is there any way to do it ??
Please comment !
|
|
|
|
|
Insert your dialog code somewhere in your applications InitInstance() , before creation if the FrameWnd.
At this point is not much of the framework (like Doc, View) already running, but for a login dialog this should be no problem.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I want to write a program need to read some doc file, but I don't have office, who can tell me how to get the text content of the word doc?
thanks
|
|
|
|
|
- suggestion 1 : try to open a .doc document with notepad. You'll figure out the content is actually clearly displayed (without all the formatting).
- suggestion 2 : use OLE/DocViewer to figure out the storage/Stream hierarchy from the .doc internal, then it's easy to grab a code from somewhere which opens a given IStorage/IStream and reads its content.
- suggestion 3 : buy a third-party lib for a couple bucks.
|
|
|
|
|
I need to insert "Control List" in SDI view . Where do I have to place code to add columns in that control List ??
|
|
|
|
|
If you mean the standard list control, derive your view from CListView , and add columns in the view's OnInitialUpdate() function.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
Hi! I'm a sig virus. Attach me to the end of your sig to help me take over the world!
|
|
|
|
|
Hi friends,
I am working in VC 6.0 SDI, I am having three pages (different bitmaps as background), I am using Function keys to select the pages. I am using BitBlt function to show the Bitmaps on the screen. I am drawing on the foreground of this bitmaps. My doubt is when I switch between the pages I want to remember the content I drawn already. Can I use BitBlt function for remembering this content with my screen as source and memory as destination so that I can use this memdc for drawing. I tried but it didn't seem to work. Can any body suggest what to do??
cheers,
Satya
|
|
|
|
|
I want a nice GUI on SDI view. Is it possible to make the layout on canvas (ie adding edit , button, radio etc controls) and embedding it on view ?? Or any alternate way...
Please comment!
|
|
|
|
|
Since it sounds like you're using MFC, check out CFormView. You use the dialog editor to lay out the controls, then the dialog gets placed in a frame window.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I'm adding a menu item to the IE standard context menu (See: Adding Entries to the Standard Context Menu http://msdn.microsoft.com/workshop/browser/ext/tutorials/context.asp?frame=true[^]) and I want this to launch my application. I can get it to open a HTML page stored in a resource in my application, in a HTML dialog, but that's not what I want.
What I'm trying to do is:
a) User selects text in IE and right clicks on it.
b) They choose my new contect menu item.
c) My app starts, if it isn't already running and gets the selected text.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
I do not know enough javascript so there might be another easy alternative , but anyway here is my suggestion.
You can access COM components through Javascript's createactivex method, from inside the component you can do whatever you want. I'm not sure if you can access the shell through javascript etc which should be the straight forward method.
And instead of having to execute html inside resource, you can simply put the necessary javascript in the html page and point to that location in the registry.
Let me know if you find any other alternative.
regards
Kannan
|
|
|
|
|
Hi Kannan,
Using a COM component sounds like it will work. Unfortunately this is one area I don't have any experience. I assume ATL would be the way to go, but I have done any ATL either! It wouldn't have a UI and should only be a few lines of code. Can you give me a URL where I can read about writing a COM object which can be accessed from a HTML page. I've looked around MSDN and couldn't find anything obvious.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|