|
Using UpdateData(TRUE) would have been too simple, isn't it? Btw, when do I call these functions?
What I want to do is to update another control when the user changes the selection.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Michel Prévost wrote:
Btw, when do I call these functions?
You should be able to call them from your CBN_CHANGE (from memory & it's early - something like that) handler. Heck, you could even put them in your DoDataExchange() method if you just want to keep using UpdateData() (make sure you only do it when going one way).
|
|
|
|
|
tx i will try those for sure
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
You need to call UpdateData(FALSE) in your handler to get the current value updated from the combo. Then you can do your other processing and call UpdateData(TRUE)
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Phil, I think it is the reverse. Anyway, UpdateData(TRUE) don't get the value from the combo box.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I have a small class that I am working with, however when I try to compile main I get some strange errors. Any clues? Thanks
Errors
<br />
--------------------Configuration: hw3 - Win32 Debug--------------------<br />
Compiling...<br />
hw3.cpp<br />
c:\documents and settings\user\desktop\hw3\hw3.cpp(6) : error C2143: syntax error : missing ';' before 'PCH creation point'<br />
c:\documents and settings\user\desktop\hw3\hw3.cpp(6) : error C2239: unexpected token '{' following declaration of 'days_array'<br />
c:\documents and settings\user\desktop\hw3\hw3.cpp(6) : error C2513: 'int' : no variable declared before '='<br />
c:\documents and settings\user\desktop\hw3\hw3.cpp(7) : fatal error C1903: unable to recover from previous error(s); stopping compilation<br />
Error executing cl.exe.<br />
<br />
hw3.obj - 4 error(s), 0 warning(s)<br />
hw3.cpp
#include "hw3.h"
int days_array{} =
{
31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31
};
int main()
{
Date today
today.set(03, 01, 1994);
for (int I = 0; I < 370; ++I)
{
today.increment();
today.display();
}
return 0;
}
hw3f.cpp
#include <iostream.h>
#include "hw3.h"
void Date::setdate(int month, int day, int year)
{
Date::month = month;
Date::day = day;
Date::year = year;
}
void Date::increment()
{
int i = day++;
if(i > days_array[month])
{
if(month == 12)
{
month = 1;
day = 1;
year++;
}
else
{
month++;
day = 1;
}
}
else
{
day = i;
}
}
void Date::display()
{
cout << month << "/" << day << "/" << year << endl;
}
hw3.h
#ifndef hw3_h
#define hw3_h
class Date
{
private:
int month;
int day;
int year;
public:
void setdate(int, int, int);
void increment();
void display();
}
#endif
Nick Parker
“Nothing is less productive than to make more efficient what should not be done at all.”
-Peter Drucker
|
|
|
|
|
in hw3.h you need a semicolon after the closing brace in your class declaration.
#ifndef hw3_h
#define hw3_h
class Date
{
private:
int month;
int day;
int year;
public:
void setdate(int, int, int);
void increment();
void display();
}<font color="red">;</font>
#endif
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote:
in hw3.h you need a semicolon after the closing brace in your class declaration.
Thanks PJ , I completely missed that.
Nick Parker
“Nothing is less productive than to make more efficient what should not be done at all.”
-Peter Drucker
|
|
|
|
|
And one after: "Date today" in hw3.cpp
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
the 3 lasts errors come from this:
int days_array{} = {31, 28, 31, 30, 31, 30,31, 31, 30, 31, 30, 31};
I suppose, you wanted to write that:
int days_array[12] = {31, 28, 31, 30, 31, 30,31, 31, 30, 31, 30, 31};
.... I think ....
Hello World!!!
from Raphaël
|
|
|
|
|
i hope that someone can answer this question cause i spent about two hours on it last night and came no closer.. I have this sample code on socket programming, but it says that i have to link in the ws2_32.lib for support of some classes. Unfortunately i don't know how to enable this option in visual studio.net!!!! can anyone answer this. Can i compile socket programs using the visual IDE or does it have to be done with the command prompt. If so, could you help me find a tutorial that might help on using the command prompt compiler? Thanks, any help would be appreciated. I have joined this group because a lot of you seem well experienced with visual c++. i am dying to make some socket programs..
xai
xai
|
|
|
|
|
i have tried this:
in the solution explorer > right clicked on the project name > properties > expanded linker (folder) > input >
then in the additional dependencies i tried two things..
first i put the path C:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\lib .....<didn't work="">.....
then i just put C:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\lib\ws2_32.lib ....<didn't work="">....
then i just put ws2_32.lib and again. ....<didn't work="">.....
xai
|
|
|
|
|
If I have to link to an extra library, I usually use a #pragma in the .cpp file that requires it.
#pragma comment(lib, "ws2_32.lib") Or, you could use the project settings dialog
- Project menu -> Settings (or Alt-F7)
- Link tab
- Object/Library modules edit box
- Add ws2_32.lib to the end of the list
HTH
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
are you using visual Studio.net cause i am and i don't see a settings and when i press (Alt-F7), it does nothing. also when i am in the property pages dialog all i see is a bunch of folders, one of which is called linker... so i open that and i see these options..
-additional dependencies
-ignore all default libraries
-ignore specific library
-module definition file
-add module to assembly
-embed managed resource file
-force symbol references
-delay loaded dlls
i have tried putting this line in all of the above
C:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\lib
with no luck!
am i in the right dialog... is that right way to do it??
also when i used that #pragma, it didn't help i am still receiving this error.
Fatal Error C1010 unexpected end of file while looking for precompiled header directive
<snippet>
#include <winsock2.h>
#include <stdio.h>
#pragma comment(lib, "ws2_32.lib")
void main(int argc, char **argv)
{
WSADATA wsaData;
SOCKET s;
SOCKADDR_IN ServerAddr;
int Port = 5150;
int Ret;
xai
|
|
|
|
|
xai wrote:
Fatal Error C1010 unexpected end of file while looking for precompiled header directive
Did you #include "stdafx.h"?
Alt-F7 is for VC6, sorry about that. But VC7 should have something similar.
xai wrote:
so i open that and i see these options..
-additional dependencies
Should be the one. type "ws2_32.lib" (no quotes) in there and see what happens
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
pj, you rock! thanks! i can finally get back to the fun part.
xai
|
|
|
|
|
Hi all,
I have two question regarding win programming.
I have a simple application.
***********************
char str[10];
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_LBUTTONDOWN:
sprintf(str, "arg1 = %d, arg2 = %d" , argv[1], argv[2]);
MessageBox(NULL, "Hello", str, __FILE__, MB_OK);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(
0,
g_szClassName,
"theForger's Tutorial Application",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 480, 320,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
*****************************************
First question is:
How to give argv[1] argv[2] etc arguments to win app as one can give to console application.
What I want is when left button is clicked the argument given to the program should appear in a dialog box.
Better if you send me a simple code example.
My second question:
I am using Visual Studio C++ 6.0.
Say, the above app is Test.exe and I want to run this application a number of times with different arguments though Visual studio IDE and not through a batch file on dose command.
Now my question is, is there any way I can write a script in VS C++, like a bat file in dose and if so how?
Script file may look like:
Test.exe 2 3
Test.exe 4 5
Test.exe 6 7
Test.exe 8 9
Test.exe 10 11
............
...........
thanks in advance
regards
/rsasalm
|
|
|
|
|
Use the GetCommandLine() function to get your program's arguments. There are also __argc and __argv, which is a VC featue that the compiler sets up. You can use those variables just like argc/argv.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
1.) What is wrong with the LPSTR lpCmdLine parameter of the WinMain() function?
2.) - "Project" menu -> "Settings" (or Alt-F7)
- "Debug" tab
- "Program Arguements" edit box
- Enter what ever program arguments you want to pass to your program
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks PJ and others,
The solution suggested by PJ works if I run the program only once. What about if I want to run the program a number of times with different arguements, as I mentioned in my orginal mail.
I don't want to use bat file. What I need is a alternative way to bat file but through VC++ IDE. Is there any way to write bat file through VC++ IDE?
thanks again
regards
/rsasalm
|
|
|
|
|
A few months ago someone had a tricky resolution to enabling a button only if the CEdit had text in it. It was really elegant and succint, but I cant find it by doing a search of CP messages. Anyways, I cant test this out at the moment but wil this work?
void CAddKeyword::OnChangeEditaddnewkeyword()
{
CString tempNKW;
m_editAddNewKeyword.GetWindowText(tempNKW);
if(tempNKW != "")
m_editAddNewKeyword.EnableWindow(TRUE);
}
In onInitDialog I had done:
m_editAddNewKeyword.EnableWindow(FALSE);
Thanks,
ns
|
|
|
|
|
it will work!
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
If you also want the button to disable again when the edit gets empty (if the user for instance deletes what she previously entered) you've got to be slithgtly change your code:
void CAddKeyword::OnChangeEditaddnewkeyword()
{
CString tempNKW;
m_editAddNewKeyword.GetWindowText(tempNKW);
m_editAddNewKeyword.EnableWindow(tempNKW.IsEmpty()?FALSE:TRUE);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That was me!
And the solution was:
void CAddKeyword::OnChangeEditaddnewkeyword()
{
CString tempNKW;
m_editAddNewKeyword.GetWindowText(tempNKW);
m_editAddNewKeyword.EnableWindow(tempKNW.GetLength() > 0);
}
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|