|
if CRealTime is declared in the calling class's header file, you'll need to make a forward class declaration so that the compiler knows that it's a class when it compiles the header. Here's an example:
class CRealTime;
class CCallingClass : public CSomeClass
{
CRealTime m_RealTime;
};
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
I am trying to do some data validation on a dialog application and present the user with a message box when the user tries to input invalid data. The test work but when it gets to the point that it is supposed to display a message box, the dialog application greys out as if it no longer has the focus, but no message box is shown and the application hangs. At this point, I have to do the control alt delete to get it to close. Help! Oh this is with Visual C++.net.
Thanks for any help!
Chris
|
|
|
|
|
when should it get called? How do you do it? How and when do you the validating?
this will help all the ones trying the answer your answer .
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
The validation is occurring when a user pushes a button on the dialog. The validation is on an edit control. See below.
int Pos;
int NumChars;
BOOL RtnVal=TRUE;
CString strEditText;
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
pEdit->GetWindowText(strEditText);
NumChars = strEditText.GetLength();
for(Pos = 0; Pos < NumChars; Pos ++)
{
if(!isdigit(strEditText[Pos])&&(strEditText[Pos]!='-')&&(strEditText[Pos]!='.')
{
RtnVal = FALSE;
}
}
if(RtnVal==FALSE)
{
MessageBox("One or more of the values you typed are not numeric!", "Error", MB_ICONERROR | MB_OK);
}
Hopefully this will help you help me!
Thanks for any help!
Chris
|
|
|
|
|
First it looks as though your missing a ')' at the end of your if statement.
Programmer_Chris wrote:
if(!isdigit(strEditText[Pos])&&(strEditText[Pos]!='-')&&(strEditText[Pos]!='.')
Second why don;t you do this
Programmer_Chris wrote:
if(!isdigit(strEditText[Pos])&&(strEditText[Pos]!='-')&&(strEditText[Pos]!='.'))
{
MessageBox("One or more of the values you typed are not numeric!", "Error", MB_ICONERROR | MB_OK);
}
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Programmer_Chris wrote:
MessageBox("One or more of the values you typed are not numeric!", "Error", MB_ICONERROR | MB_OK);
Is the message box actually displayed? Unless you are using ATL, or you have your own flavor of MessageBox() , shouldn't there be four parameters with the first one being the handle to the owner window?
While not related to the problem, I would suggest terminating the for loop once an invalid character is found.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
I have placed a Check Box on 1st property page.
The propertysheet containing this property page is on the form view of my MDI MFC Appwizaerd
Application.
I have placed a push button on form view of the application.
In its(push buton's) member function, named OnPress, I want to fetch the value of the checkbox
of that propertypage.
ID of Check Box is IDC_CHECK_SUBFOLDER
If I place the code as follows in OnPress member function, I get an access violation error when
I run it.
(((CButton *)GetDlgItem(IDC_CHECK_SUBFOLDER))->GetCheck() == 1);
Please Help me to fetch the value.
Drushti
|
|
|
|
|
missnazar wrote:
(((CButton *)GetDlgItem(IDC_CHECK_SUBFOLDER))->GetCheck() == 1);
It's never a good idea to use hard-coded values like this. Compare against BST_CHECKED instead. That's not the cause of the access violation, however.
Rather than lump all that into one convoluted statement that makes debugging rather difficult, how about breaking it up into something like:
CButton *pButton = (CButton *) GetDlgItem(IDC_CHECK_SUBFOLDER);
if (NULL != pButton)
{
if (pButton->GetCheck() == BST_CHECKED)
;
} Now you can get a better idea as to where it's failing.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
Rather than lump all that into one convoluted statement that makes debugging rather difficult, how about breaking it up into something like:
Once the problem is fixed, would you put the code back to a single line? Whilst it is not as 'nice' to read I imagine it would execute quicker, not that the difference in speed will amount to much anyway. I just wondered what other people thought - more convulated, easier to read/maintain code, or 'many commands nested on one line'.
Cheers
Angel
***********************************************************
The sooner you fall behind, the longer you have to catch up
|
|
|
|
|
Angel1058 wrote:
Once the problem is fixed, would you put the code back to a single line?
I personally would not.
Angel1058 wrote:
...I imagine it would execute quicker...
True, assuming your stopwatch can measure things in nanoseconds.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello there,
I want to draw the frame around my edit controls myself.
Where should I start???
The WM_PAINT message doesn^t seem to get send untill I enter data in the control, so that`s not the way... Which message should I capture so that I can draw the frame of my edit control myself?
Thx for any help you can give.
Greetz,
Davy
|
|
|
|
|
Probably WM_NCPAINT (Non-Client paint)
If you vote me down, my score will only get lower
|
|
|
|
|
Hi!
Is there anyway of se which ethernet cards that exists on your computer? I would like to choose which one of them to use when I program a Socket with C++. For example you can have one ethernet-card that are wired and one that are wireless. How can I in Visual c++ .net choose which one to use?
Do microsoft have an class or library for this?
It would be very good if someone only have an idea of this.
/Martin
/Martin
|
|
|
|
|
why don't you take the easy way and let windows decide whats the best interface to use?
Don't try it, just do it!
|
|
|
|
|
I can´t because we are suppose to have a seamless communication between them. If you unplugs the cable for example the application shall use the wireless communication instead of the wired without loosing any data.
Is it possible to choose in any way instead of letting windows do it for you?
/Martin
|
|
|
|
|
Hi,
I need to write a little app which loads an image file (bmp, jpg or png), displays it, accesses pixel info and paints flat colour rects onto the image (- don't ask, it's a long story!).
Anyway I've done a fair bit of playing with MFC and Win32 over the past year but haven't yet touched graphics work. I intend to do a lot of graphics stuff in the future. Could anyone suggest the best approach to doing this project with a view to it giving me an intro to graphics work. Should I be concentrating on the Win32 api or GDI+ or DirectX or something else? I've no experience of GDI or DirextX at all. What are the strengths and weaknesses. All my future graphics work is likely to be 2D based.
Any advice would be much appreciated.
Many thanks,
Simon
|
|
|
|
|
If you search for CxImage on this site, you will found a nice library for working with images and image data for many graphics formats. You could do this all yourself, but why bother, since others have been down this path already.
When you say "doing graphics work," are you going to be concentrating on a GUI approach, or on a processing approach? Much of my work involves graphics processing, but there isn't much of a GUI since all the data comes from other places, is processed, and then output and manipulated in various formats without user intervention.
If your graphics work is directed toward gaming, then that is a different topic.
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
Hi Dave,
Thanks for the reply. I took a quick look at CxImage and did think it looked ideal. The thing that put me off is that the author implies it has now been superseded by other technologies - I didn't want to spend time getting to grips with something then to realise I have to get to know GDI+ or DirectX.
I know DirectX is heavily used for games. A few of the projects I'm interested in looking at include playing back image sequences using RAM buffers, and importing, scaling, compositing and displaying image files in an application environment. As these are pretty performance driven I wondered if DirectX's 2D capabilities may be desirable.
I also heard there's a new display technology available through Longhorn, and would rather spend time learning something that will be around for a while.
Anyhow, your suggestion of using CxImage has confirmed my feeling that it is probably a good place to start so I'll check it out again.
Cheers Dave,
Simon
|
|
|
|
|
You know, it really is as if you had a nail. All you want to do is pound the nail into something, so you think about looking at hammers. There are wooden handled hammers and graphite handled hammers. There are framing hammers and finish hammers. Depending on exactly what you want, any of them could do the job. Which is better? Well, it depends.
CxImage is primarily MFC/Win32 based. I've used it without needing GDI+ or DirectX. I've looked into OpenGL too, but that didn't really fit my needs. I may use OpenGL later for something different, but I didn't need it now. They all have strengths and weaknesses, just like hammers, for specific tasks. I know that's what you're asking about.
Which one should you focus on? That's hard to say. Any of them can do the job, but they will do it in different ways. Make this series of function calls versus that series of function calls. Do you just want to get started with something? Or, are you concerned about ultimate performance, cross-platform compatibility, ease of programming, future of technology support, etc?
At this stage, I think it's just better to pick something and go with it. Which one probably won't make much difference right now.
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
Hello !
I need to design a Wizard to configure my programs (via configuration files). I want to know if it's possible, with a CPropertySheet in Wizard mode, to do thinks like that:
1) At first, add just 1 or two pages in the wizard. These pages will be used to select wich applications must be installed and things like that.
2) With the user choice made in step 1, in need to add pages to the wizard (1 page to configure each application -> so the number depends of how many app have been chosen in step 1 )
3) On each page, when the user click Next, I need to get the data he has selected. So here, what I need, is override the 'next' handler, get the page index and get all the data on the propertyPage to store them somewhere
4) When the user select Back, I need to show the previous Page with the previous data (so not default data but the data he had chosen before...)
So I want to know if all these things are easily possible using a PropertySheet ? And if possible, point me in some directions
|
|
|
|
|
Are you using MFC?
If so, all of this is easy to do...
1. Add initial pages - CPropertySheet AddPage
2. Yes, again, use CPropertySheet AddPage. You can also remove pages with CPropertySheet RemovePage
3. Process data in CPropertyPage OnKillActive or else CPropertyPage UpdateData (Data Exchange Handlers). As for storing, make a separate singleton data container class to hold all the information for the program, access it via a gobal accessor function.
4. Same as 3, except you might be interested in the CPropertyPage OnSetActive.
|
|
|
|
|
Hello,
I have a problem, this is the following.
I make a a form. There is a button on the form.
The form have a event execute ShowInTaskBar is false.
The Button have 3 event, 1st event is MouseLeave event, this is BackColor of it is black, 2nd event is MouseEnter event, this is BackColor of it is white, 3rd event is ButtonClick event, this is ShowInTaskBar is true.
Before I click a button, mouse event is enable. but after I do it, mouse event is disable. This condition is a button's backcolor is white, not change black yet.
private void button1_MouseLeave(object sender, System.EventArgs e)
{
button1.BackColor=Color.Black;
}
private void button1_MouseEnter(object sender, System.EventArgs e)
{
button1.BackColor=Color.White;
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.ShowInTaskbar=false;
}
private void button1_Click(object sender, System.EventArgs e)
{
this.ShowInTaskbar=true;
}
I think this is bug of .NET. But I resolve this problem. If you have some solutions, please tell me.
Cheers,
yu-yu
|
|
|
|
|
Hi there !
Im stuck with my win32 application where I want to add an bitmap to a control button in a dialog.,
Im tryin to use the BM_SETIMAGE message but I dont get it to work... I have a bitmap IDB_BACKWARD_BITMAP defined in the resource.rc and given an id in resource.h
The control button IDC_BUTTON1 that I want to attach the image to is defined in the resource.rc
here is my callback function for the dialog window that also contains an combobox etc but its not displayed here.
LRESULT CALLBACK ToolboxProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
LRESULT iComboBoxSelection;
switch(Msg)
{
case WM_INITDIALOG:
SendMessage(GetDlgItem(hWndDlg,IDC_BUTTON1), BM_GETIMAGE, IMAGE_BITMAP, IDB_BACKWARD_BITMAP);
..............
I have also tried a version where I load the bitmap like this;
Bitmap=LoadBitmap(t_hInst,MAKEINTRESOURCE(IDC_BUTT
ON1));
SendMessage(GetDlgItem(hWndDlg,IDC_BUTTON1), BM_GETIMAGE, IMAGE_BITMAP, Bitmap);
Where I have defined HINSTACE t_hInst global but is there anything else that I have to do with it? and i also get an error
"cannot convert parameter 4 from 'BITMAP' to 'LPARAM'
......
Any help would be grateful because I dont have any clue about what to do
Regrads
/Peter
|
|
|
|
|
|
I want to use wave file in my project.
When i click button,some music is appear.
|
|
|
|
|