|
First) How you construct your ListBox.? In what event?
Second)Please write part of the code....
Carlos Antollini.
|
|
|
|
|
|
Hello, the codegurus around the world.
You should understand the diff bet Model and Modeless Dialog.
Modeless dialog never stops the main process, but Model Dialog
stops the main process like the message box.
So, this means that you must add the item to ListBox on Model dialog
by OnInitDialog, or you can use timer or thread code in Model dialog to add the item to ListBox outside of OnInitDialog when you want to add the item
to ListBox from the control outside this model dialog.
Or you can create the model dialog by the different process, and get CWnd
of this ListBox, you can add the item to ListBox from any application.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I have rarely used any STL in my 2 years of c++, but I wanted to learn a bit more about it, so I started by reading the one chapter in Deitel and Deitel on it. But my first example from that book generated a bizare error in MSVC. Does MSVC support STL properly and do I need to do something especial? Or is
my book too old and the STL standards changed too much since this book was written in 1997.
Here is the code:
#include <iostream.h>
#include <iterator>
using namespace std;
int main()
{
cout << "Enter two integers.";
istream_iterator< int > inputInt( cin );
int number1, number2;
number1 = *inputInt; //read first int from standard input
++inputInt; //move iterator to next input value
number2 = *inputInt; //read next int from standard input
cout << "The sum is : ";
ostream_iterator <int> outputInt(cout);
*outputInt = number1 + number2;
cout << endl;
return 0;
}
And here are the 2 errors:
Compiling...
main.cpp
c:\C++\STL\Fig205\main.cpp(14) : error C2664: '__thiscall std::istream_iterator<int,char,struct std::char_traits<char=""> >::std::istream_iterator<int,char,struct std::char_traits<char=""> >(class std::basic_istream<char,struct std::char_traits<char=""> > &)
' : cannot convert parameter 1 from 'class istream_withassign' to 'class std::basic_istream<char,struct std::char_traits<char=""> > &'
A reference that is not to 'const' cannot be bound to a non-lvalue
c:\C++\STL\Fig205\main.cpp(23) : error C2664: '__thiscall std::ostream_iterator<int,char,struct std::char_traits<char=""> >::std::ostream_iterator<int,char,struct std::char_traits<char=""> >(class std::basic_ostream<char,struct std::char_traits<char=""> > &,
const char *)' : cannot convert parameter 1 from 'class ostream_withassign' to 'class std::basic_ostream<char,struct std::char_traits<char=""> > &'
A reference that is not to 'const' cannot be bound to a non-lvalue
Error executing cl.exe.
Fig205.exe - 2 error(s), 0 warning(s)
|
|
|
|
|
This code was compiled with no errors with VC++6(SP5)
#include [stdafx.h]
#include [iostream]
#include [iterator]
using namespace std;
int main()
{
cout [[ "Enter two integers.";
istream_iterator[ int ] inputInt( cin );
int number1, number2;
number1 = *inputInt; //read first int from standard input
++inputInt; //move iterator to next input value
number2 = *inputInt; //read next int from standard input
cout [[ "The sum is : ";
ostream_iterator[ int ] outputInt(cout);
*outputInt = number1 + number2;
cout [[ endl;
return 0;
}
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
|
|
|
|
|
Hey guys
I want to use a file to store settings for my program preferably an ini file. Are there and API function that control writing and reading to and from ini files so all i have to do is put the data in rather then having to worry about the layout.
Cheers
Peter
|
|
|
|
|
See CWinApp::G/SetProfile...() and G/SetPrivateProfile...().
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
WritePrivateProfileString() and GetPrivateProfileString() does what you want.
Why don't you use the registry instead?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
And don't forget the GetPrivateProfileInt() and WritePrivateProfileInt() functions.
Carlos Antollini.
|
|
|
|
|
The functions mentioned previously are provided by Windows for backwards compatibility. You should use the registry unless you have compelling reasons not to, such as a huge amount of data to store and you don't want to bloat the registry (like it needs your help), or you want users to access and modify the file.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
One simple Question:
I have a HWND from a window found by EnumChildWindows.
It is an edit-control.
How can I get the text of this window?
GetWindowText does not seem to work, the MSDN says as follows:
If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control.If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string.
i.e., since the edit-control I have found belongs to a different thread, the returned window-text is always null.
How can I get the text?
SetWindowText also doesn't work, because the Window belongs to a different thread.
any suggestions?
thanks
|
|
|
|
|
Maybe the hilighted text from MSDN refers to non-child windows, that can have a caption. An editbox doesn't, and since sending a WM_GETTEXT can't work for another process, the function fails and returns zero.
Just supposing though, I'm not sure
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
I was just working on a program that needs to do what you are asking. The problem here, is that you do not know how much text is in the control in order to read it. To exaserbate the problem further, you cannot get a pointer to the buffer that holds the text, because different controls keep the text in different places.
The solution is to send a pair of messages to the window you want to extract text from. The first queries the window for the size of the text it contains, and the second retrieves the text. Some sample code:
int len = ::SendMessage( hWnd, WM_GETTEXTLENGTH, 0, 0 ) + 1;
TCHAR* text = new TCHAR[len];
::SendMessage( hWnd, WM_GETTEXT, len, LPARAM( text ) );
delete[] text;
Adding one(1) to the length is important, because the WM_GETTEXTLENGTH message does not include the terminating null character in the length. Using the TCHAR type will allow your code to compile on both ANSI and Unicode environments.
One caveat: You cannot extract the text of a password-protected edit field on Win2k and WinXP. Microsoft finally plugged that little security problem
--
Paul
"I drank... WHAT?"
|
|
|
|
|
Hello, I'm really new to C++ and windows programming trying to teach it to myself. so I picked a simple and silly project, I'm trying to write my own keyboard drivers for the special shortcut keys on my keyboard. I only say driver for lack of a better word, as I really have no intention of using DDK, I simply want to use a windows hook to redierct them but I can't fiquire out how to the OEM scan code out of the lParam of KeyboardProc and the they aren't defined as virtual-keys (I assume because the manufacturer seems to be using a hook as well) any help would be appreciated
Thanks,
ßlack Widow
|
|
|
|
|
I'm working on a program and I need the back ground of my static tect controls to be black and the text to be White. How whould I go about making these changes??
Thanks ~
|
|
|
|
|
|
Thanks, that answered my question about the background color, but id does not help me with setting the static text text color ... any suggestions.
Thanks ~
|
|
|
|
|
Read up on the CDC functions (or equivalent Win32 APIs if you're not using MFC). SetTextColor will, as the name says, set the text color.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
How can we over ride the WindowProc() in an ATL composite control. I need this to add hot keys to my application.
Thanks in advance,
Rejeesh.
|
|
|
|
|
ok so i make an app shell and put in a flexgrid control.
the grid is 7x7
here's my prob:
-the first column is static, never changes. i need to put in 7 labels.
-the second column will change, it contains dollar values i.e $400.00. the information in this column repeats itself across the span of the remaining columns.
-i need 1 button to display the dollor values and 1 button to clear them leaving the first column unchanged.
i've tried useing an example for this but it uses a random generator and i can't get the items to appear in the order i want them in. please help!!
|
|
|
|
|
I have a Win32 application which has a toolbar, dropdown menu, and utilizes hotkeys.
I enable/disable buttons on my toolbar/menu based on certain criteria which is changed during program execution.
Where is the best place in my code to tell the toolbar/menu to make desicions about enabling/disabling buttons? It seems a bit messy to call my Toolbar_Update() function everytime something is executed from the menu or toolbar.
Is there some kind of call back or something I could use?
I mean, calling this Update function everytime does the trick, but I'm not sure that its all that clean.
Mike.
doner@obtain.com
|
|
|
|
|
You could set up an idle message loop to do your updates ( in your main message loop ), this is the most common way I've seen it done ( MFC/WTL/OWL do it this way ).
Thought the way your curently doing it is just as good as any.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Hi again. Man, I can't get anything working today. I am getting a FILETIME back from my file search and I want to convert it into a DATE to pass into ADO ( if it is important I am using Jet and created a DATE field in Access ). Can anyone give me any hints on how to convert between these two formats ? Or should I just store the date as a number as it comes out of my file search ?
Ta.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
You could rip the conversion function off from the MFC sources, its located in "olevar.cpp" : line # 1568 ().
It takes the form;
_AfxOleDateFromTm ( WORD wYear, WORD wMonth, WORD wDay,
WORD wHour, WORD wMinute, WORD wSecond, DATE & dtDest )
>>> [Update]
You'll also have to use FileTimeToLocalFileTime() and FileTimeToSystemTime() to get a usable date structure ( namely SYSTEMTIME ).
FILETIME fileTime; <br />
<br />
FILETIME localTime;<br />
FileTimeToLocalFileTime ( &fileTime, &localTime );<br />
<br />
SYSTEMTIME sysTime;<br />
FileTimeToSystemTime ( &localTime, &sysTime );<br />
<br />
DATE theDate;<br />
_AfxOleDateFromTm ( stCreate.wYear, stCreate.wMonth, stCreate.wDay,<br />
stCreate.wHour, stCreate.wMinute, stCreate.wSecond, theDate );
<<< [Update]
Hope this helps.
Have a good one,
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Christian, is easy, convert the FILETIME to COleDateTime then convert the COleDateTime to variant for send to Ado.
Please Christian see in the classes that I sent you, you can see that conversion in the method SetFieldValue....
Cheers!!!!
Carlos Antollini.
|
|
|
|