|
Yes it did. Thanks very much;)
|
|
|
|
|
I need to make a progress control using GDI+ that can be added at runtime.
How would you go about implementing graphically the bar. Would you use a
rectange and keep inflating it? Any suggests would be appreciated.
Steve
|
|
|
|
|
Hi,
I'm making an app with a static splitter and in one of the panes I have a control view. I would like to set the size of the control pane to match that of the dialog resource. I prefer to do it programatically if it's possible, so that it updates automatically whenever I change the dialog.
I know how to set the sizes in the splitter with SetColumnInfo, so I just need a way to get the correct size from the resource.
thanks
Ludde
|
|
|
|
|
Use this code in your CDialog derived class (class associated with your dialog resource)
<br />
CRect rect;<br />
GetWindowRect(&rect);<br />
hope that helps
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
I did some searching as i once read such a problem and the solution as well
Lucky You I found it
Below is an Excerpt from C++Q&A (SEPEMBER 1998) by Paul Dilascia
Hope it Helps
A) This is a typical Windows chicken-and-egg problem, one of those things that seems like it should be easy but isn't. One way to find the size of a dialog is to load the dialog resource into memory—that is, into a DLGTEMPLATE structure—and look at the cx/cy parameters. Unfortunately, these values are in dialog base units, not pixels. So you have to call GetDialogBaseUnits and do some coordinate conversions, which depend on whether your dialog uses the system font or its own font.
Fortunately, there's an easy and surefire way to find out the size of a dialog, even if it is a bit kludgy: just create the dialog, and see how big it is! Of course, you have to create it invisibly if you don't want the user to see what you're doing. But the dialog used for a form-based app is invisible by default, so in this case making the dialog invisible doesn't require extra effort.
To see how it works, I added the automatic sizing feature to the FormSwap program mentioned in the answer to the previous question. The core of the autosize feature is a static function, GetDialogSize, which gets the size of the form. Yes, even in the days of C++, I still write static functions from time to time. But GetDialogSize is implemented using a C++ class, CTempDlg:
class CTempDlg : public CDialog {
public:
CRect m_rcDlg;
protected:
virtual BOOL OnInitDialog();
};
BOOL CTempDlg::OnInitDialog()
{
GetWindowRect(&m_rcDlg);
m_rcDlg -= m_rcDlg.TopLeft();
EndDialog(0);
return TRUE;
}
CTempDlg has just one function override: OnInitDialog. OnInitDialog saves the position of the dialog in a data member, then quits. (MFC does a bit of trickery to allow this; in straight C you can't call EndDialog from within WM_INITDIALOG.) GetDialogSize uses CTempDlg to get the dialog's size, which it returns as a CSize.
CSize GetDialogSize(LPCTSTR pszTemplName,
CWnd* pParent)
{
CTempDlg dlg;
dlg.Create(pszTemplName, pParent);
return dlg.m_rcDlg.Size();
}
Pretty simple. If you try this at home, just remember that the dialog should have no borders and should be invisible (dialogs used in form views always are).
If you want to get the size of a normal dialog, you'll have to do a bit more coding. To first load the dialog template into memory, turn off the WS_VISIBLE and WS_BORDER styles in the DLGTEMPLATE structure and call CDialog:: CreateIndirect instead of Create. If you're already loading the dialog into memory, you may as well just convert the cx and cy values using GetDialogBaseUnits. In passing, I should also mention another function, MapDialogRect, that converts dialog box units to screen pixels. However, this function requires an HDLG, which is an already created dialog.
Once you have the size of the dialog, you've solved the main problem of sizing your frame—but you aren't out of the woods yet. Now the problem is: given that you know how big the dialog is (that is, how big the client view area should be), how big must you create your main window to get a client area exactly that size? This sounds simple but it turns out to be a real pain in the keyboard. There's a virtual function, CWnd::CalcWindowRect, that's supposed to accomplish this feat. Given a certain-sized client rectangle, it calculates the corresponding frame rectangle. Unfortunately, no one in Redmond bothered to implement this function for CFrameWnd. So that leaves it to you.
Implementing CalcWindowRect is an exercise in nit-picking, or should I say pixel-picking. Given a certain-sized client rectangle, you have to add the heights and widths of all the toolbars, splitter borders, menus, window frames, and what-have-you. In the case of FormSwap, there are toolbars, the splitter window, and the left-pane view that must be taken into account. To calculate the height of the toolbars, you can use the MFC function CWnd::RepositionBars. You feed it a rectangle and a magic code, reposQuery—which says you only want to calculate the toolbars, not actually move them—and presto, you have the numbers you need. If you want to understand RepositionBars better, read the documentation. Good luck.
After calculating the heights of the toolbars, the next troublesome task is calculating the height and width of all the splitter window components: the border with which it surrounds each pane and the splitter bar itself. All these magic numbers are contained within data members in CSplitterWnd, but naturally the data is protected, which means you can't access it! Sigh. So what do you do? Simple: just derive a new class with public functions to export the protected data, and use it instead of CSplitterWnd in your main frame.
class CMySplitterWnd : public CSplitterWnd {
public:
CSize GetBorderSize()
{ return CSize(m_cxBorder,m_cyBorder); }
CSize GetSplitterSize()
{ return CSize(m_cxSplitter,m_cySplitter); }
};
If you're lazy (the best programmers are), you might be tempted to just hardwire the border size and other measurements instead of going to all this trouble. But be warned: the values m_cyBorder and its sisters are different under Windows 3.1, Windows 95, and Windows NT®. So if you want the exact values, you must get them from an instantiated CSplitterWnd object.
By now you've probably fallen asleep just thinking of all this tedious work, but once you've calculated how big your main frame should be, the next step is to actually modify the frame's size. Where do you do it? There are oh, so many places. You could override PreCreateWindow and set the size in CREATESTRUCT, implement a WM_GETMINMAXINFO handler, or alter the size in CFrameWnd::OnCreate. In this particular case, however, there's only one option because the magic RepositionBars function works only after the toolbars have been created. This means the winner is door number three: OnCreate.
int CMainFrame::OnCreate(...)
{
•
•
•
static CSize sz = GetDialogSize(MAKE
INTRESOURCE(IDD_DIALOG1), this);
CRect rc(CPoint(0,0), sz);
CalcWindowRect(&rc);
SetWindowPos(NULL, 0, 0,rc.Width(), rc.Height(),
SWP_NOMOVE|SWP_NOZORDER);
return 0;
}
With this and all the other code in place, the window now appears as in Figure 1, just large enough to enclose the form, and not one pixel larger. Whew!
Before signing off, let me spend a few words on WM_GETMINMAXINFO. Windows sends this message just before creating a window, and again whenever the user attempts to move or size it. WM_GETMINMAXINFO is your opportunity to specify the minimum and maximum sizes allowed for your window. If, after going to all that trouble to calculate the window size, you want to prevent the user from decreasing the size of the window, you should handle WM_GETMINMAXINFO. Just follow the directions in your Win32® Owner's Manual. Don't forget that Windows sends the first WM_GETMINMAXINFO before it creates your window, so RepositionBars won't work. You either have to implement CalcWindowRect another way, without using RepositionBars, or ignore the first WM_GETMINMAXINFO message. One way to do this would be to make the dialog size a data member, m_szDlg, which you initialize to zero and then set in OnCreate. Then your WM_GETMINMAXINFO handler would do nothing if m_szDlg is zero.
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Thank you very much!! I haven't had time to dig through all of it yet, but it sure looks promising.
thanks again!
/Ludde
|
|
|
|
|
Hi,
can anyone tell me whether I can send SMS programatically. If yes, are there any references / net-links where I can get some more info.
thanks
Partho
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
You can send SMS via MAPI. You can find a sample program on web for the same.
|
|
|
|
|
Thanks,
Can I use MAPI for all mobile phone services?
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
How do I get my IP address while I am on line. I used function gethostbyname( ) and from there I used function inet_ntoa( ) to get IP address. But this IP address appears to be static. I mean it does not change whether I am on line or off line, and even after I restart my PC it is always the same.
Thanks,
|
|
|
|
|
Anonymous wrote:
I mean it does not change whether I am on line or off line, and even after I restart my PC it is always the same.
It might be. Mine is. If your PC doesn't rely on BOOTP or DHCP for configuration, you have a static address.
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
If you are using dialup you can try with GetProjectionInfo() and RasEnumConnections(). Check MSDN to know more about these funtions
|
|
|
|
|
Hello,
We have a windows app that can be started in a 'test mode'. In this mode the main window is hidden and another testing dialog is shown. The testing dialog does not have a parent window.
This is an MFC app and VWinApp->m_pMainWnd always points to the hidden main window, not the testing dialog.
When run in this test mode there is no icon on the task bar for the app. How can I make an icon appear in the task bar in this case.
Cheers
Josh
|
|
|
|
|
From MSDN :
There are two ways to prevent a window from appearing on the shell's taskbar and in the task list window that appears when you press ALT+TAB.
Give the window the WS_EX_TOOLWINDOW extended style, and remove the WS_EX_APPWINDOW style. As a side effect, the window will have a smaller caption than a normal window.
Give the window the WS_POPUP style and make it owned by a hidden window.
If a window is created or shown such that it appears in the taskbar, then the window should be in the same state when it is destroyed or hidden. If the visibility on the taskbar is not synchronized, then the taskbar may end up with a blank button where it thinks the window should still appear.
Hope that helps
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Ok im coding a project for school. What it does is reads in
Name , Last name , ID number , Gender
( 4 parrallel arrays ...)
and when you are done modifying (adding a member , sorting , removing a member..etc)
it asks to update the existing text file (overwrite)
now i know about
#include <cstdlib>
and
system("DOS command");
but i would like to put when it is updated :
is it possible to print out to a file
obviously with the fstream headerfile
ofstream dataOut...or something
THOSE DOS commands?
as like to save them into a
typedef char array[90]...
array myString; ...etc
Or am i doing this all wrong..
Even tho i know those system commands are actually int's.. 0 's ir 1 's...
|
|
|
|
|
You want to put the time that the update happened ? This from the MSDN
#include <stdio.h>
#include <string.h>
#include <time.h>
void main( void )
{
struct tm *newtime;
char am_pm[] = "AM";
__time64_t long_time;
_time64( &long_time ); /* Get time as long integer. */
newtime = _localtime64( &long_time ); /* Convert to local time. */
if( newtime->tm_hour > 12 ) /* Set up extension. */
strcpy( am_pm, "PM" );
if( newtime->tm_hour > 12 ) /* Convert from 24-hour */
newtime->tm_hour -= 12; /* to 12-hour clock. */
if( newtime->tm_hour == 0 ) /*Set hour to 12 if midnight. */
newtime->tm_hour = 12;
printf( "%.19s %s\n", asctime( newtime ), am_pm );
}
Output
Fri Jan 22 10:03:48 AM
I don't recall if it's ctime or time, but you should not include time.h as it is deprecated. This will mean that the methods you want will be in namespace std.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hello, everyone!
I want to enumerate all the files in a directory and get their names and the create time of each file.
Are there some sample codes that I can make a reference?
Best regards,
Geo
|
|
|
|
|
use CFileFind if you are using MFC or FindFirst and FindNext apis.
Programming is an art not a skill, every one can be a skilled programmer but not an artist.
|
|
|
|
|
Thanks, mr.prakash buddy!
I have resolve the trouble by the function you recommended.
Best regards,
Geo
|
|
|
|
|
How to use VideoSoft FlexArray Control and DBGrid Control! Who can tell me?
Or where can download?
|
|
|
|
|
what exaclty u need to do??
please be precise!!
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
... like I can produce with Excel ?
I have a lot of lines a columns Of different length to format and then print the result on a printer.
How can I do that ?
Any idea appreciated ...
DD
|
|
|
|
|
Crystal Reports is one solution. Reusing Excel via its automation interfaces is another. Generating HTML and pass it to the printer via Shell/IE can also be done. Another solution is to use GDI directly. The options are many (about as many as there are report libraries).
--
You're entertaining at least.
|
|
|
|
|
thanks for the answer !
1) let's forget about Crystal Report, I have not enough money to buy it ...
2) Excel ... why not, but it supposes that all station using my application has Excel installed, and I am not sure I want to have a such dependence ...
3) HTML ... Is there an easy way to produce HTML code from VC++ or do I have to handle myself all HTML tags ? Can you be more precise on this "pass it to the printer via Shell/IE" or indicate me an article where I can read something on it
4) use GDI directly : this means drawing myself all lines and columns, insert all figures, change the fonts, etc ... I think I was more or less thinking to this kind of solution ... but isn't it to hard/tedious to do this ? I will see if I can find some articles on this
Thanks again for your help
DD
|
|
|
|
|
Qadddd wrote:
Can you be more precise on this "pass it to the printer via Shell/IE" or indicate me an article where I can read something on it
You can either load IE with the result HTML, or your could use the shell API function ShellExecute to print. A simple solution is to just load the report into IE - the user usually wants to preview reports and then print it.
As for generating HTML, I think you'll have to be on the creative side there. I'd build primitives (C++ classes) for generating low level HTML. One class per element basically - and build an HTML object model from there. I'm not sure, but I think MSHTML does this already. Consult the MSDN documentation for further info on that API. Ontop of MSHTML, you can build your own abstractions like ReportHeader, ReportFooter, ReportBody, etc. Abstractions that uses and composes the MSHTML objects in concise way. This combined with CSS can yield pretty good looking reports, but it'll cost you the knowledge of HTML and CSS + various APIs.
Qadddd wrote:
use GDI directly ... but isn't it to hard/tedious to do this ?
Uh huh. That's why there's a business for report generation tools.
--
You're entertaining at least.
|
|
|
|
|