|
The button-click event.
Thanks very much in advance David.
nicolas
|
|
|
|
|
Handle the BN_CLICKED message. If you are using MFC, use ClassWizard (Ctrl+W) to create a ON_BN_CLICKED() handler.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I'using Borland C++ builder 4.0. I've got a button which Ive called btnGenerate an edit box called editA. I want to generate a number in the edit box between 0-9 on the click event of the generate button. Are you familiar with the borland C++ builder. I'm not sure I've heard of the MFC.
Many thanks nicolas.
|
|
|
|
|
Anonymous wrote:
Are you familiar with the borland C++ builder.
I've not used a Borland product in over a decade. Sorry.
Anonymous wrote:
I'm not sure I've heard of the MFC.
It's part of Microsoft Visual C++, the main topic of this board.
Anonymous wrote:
I want to generate a number ... between 0-9
When you are ready for it, here's the code:
int x = rand() % 10;
|
|
|
|
|
I'using Borland C++ builder 4.0. I've got a button which Ive called btnGenerate an edit box called editA. I want to generate a number in the edit box between 0-9 on the click event of the generate button. Are you familiar with the borland C++ builder. I'm not sure I've heard of the MFC.
Many thanks nicolas.
|
|
|
|
|
Hi all,
I have created a DLL from some C++ code (to call from my C# app).
The DLL creates and writes to a couple of files.
However, it writes them to the folder last used by the C# app.
1. Why? (Less important)
2. How do I specify where to write the file, relative to the DLL file. (More Important)
Thanks in advance for any suggestions/hints.
J
---
|
|
|
|
|
Hi,
Do you use GetModuleFileName() or GetModuleFileNameEx()?
Sincerely Yours,
RadioShark
|
|
|
|
|
No, but I am not experienced in C++.
They sound like what I need - so what's the difference.
J
---
|
|
|
|
|
RadioShark wrote:
Do you use GetModuleFileName() or GetModuleFileNameEx()?
It appears that neither of these are recognised by the compiler - do I need to include them somehow?
---
|
|
|
|
|
If you are receiving a compiler error, make sure that windows.h is included.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks anyway - have solved it another way (in the C#).
J
---
|
|
|
|
|
Care to share?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
sure -
I just set the working directory before calling the DLL.
Environment.CurrentDirectory = Path.Combine(Application.StartupPath, "Working\\");
where /working/ is the directory I want to create the output files in.
The working directory is set by other functions also.
J
---
|
|
|
|
|
This post indicated you were getting compiler errors. I don't see the relationship between not having GetModuleFileName() or GetModuleFileNameEx() recognized by the compiler, and setting the working directory before calling a DLL.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
This post was a solution to my original problem.
---
|
|
|
|
|
Dear All,
I am a new comer of this message board. First let me say hi to you all ^_^
I am working on my project in my school which require me to check if there is any new file exist in a folder by using MFC. Since I am just start learning MFC a few weeks before, I totally have no idea about how I can do so........
Would anyone give me some advice on this in details?
Really thanks a lot!
Yours,
Meteor
|
|
|
|
|
Hi,
CFile f;
char* pFileName = "test.dat";
if( !f.Open( pFileName, CFile::modeRead | CFile::shareDenyNone ) )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << "\n";
#endif
}
Sincerely Yours,
RadioShark
|
|
|
|
|
Oh....I forget to mention that I have to check it continuously, i.e. when I start the program, I have to be able to check it after clicking "Start" button and it will loop continuously to check.....
Will your method be ok on that also?
^_^
Yours,
Meteor
|
|
|
|
|
StarMeteor wrote:
...and it will loop continuously to check...
If that is your requirement, use ReadDirectoryChangesW() and/or FindFirstChangeNotification() instead.
Unless it is done infrequently, polling the OS in a loop is not very efficicent.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Oh.....actually I have looked in this site and read an article about the API you mentioned...but I don't understand it much....especially what I need to use it and how to initialize ..... T_T
|
|
|
|
|
fwatch.exe is a good example.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Oh...I found that I forget to defind #define _WIN32_WINNT 0x400 at stdafx.h in order to use the API....
I can use it now!
Thanks a lot~
|
|
|
|
|
How about _access() , or CFile::GetStatus() ?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi all!
I have a base class, CFeature, from which other classes are derived such as CFeatureLine for example. CFeature has a virtual operator, void draw(), which the derived classes always override.
Creating an instance of the derived class, CFeatureLine *pX=new CFeatureLine(...), then serializing it works fine - no problem.
However, in order to de-serialize I use the following code:
CFeature *pFeature; // i use CFeature so that any derived class may be loaded
ar >> pFeature;
But now whenever the draw function of pFeature is called, the compiler directs control to the base class draw function, and not the derived class. This might seem logical, but it appears that MFC's serialization doesn't instantiate a derived class, and instead instantiates the base class, even though the serialization mechanism is supposed to instantiate the class it was saved as.
One way round this is to store a feature type along with the feature data in order to instantiate the appropriate class upon loading, but this is very ugly, and non-modular.
Do you know of a way to solve this? Any help would be great.
Paul.
|
|
|
|
|
First: ar >> pFeature will read the pointer value, not the contents of object!
If you want to serialize objects of different types, you have to store a type information with each object, even it seems ugly to you. The stream is only a sequence of bytes, and you haven't any type information, unless you store it explicitly.
You should use the standard MFC serialization through CObject and CRuntimeClass , it is quite modular but IMHO non-elegant. And you must derive your objects from CObject , clearly.
Or you can write your own class factory. Class factory is an object, to that you pass an type ID, and the factory creates an instance of type described by the ID. For details see this article.
Robert-Antonio
"I launched Norton Commander and saw, drive C: on the left, drive C: on the
right...Damn, why I need two drives C:??? So I formatted one..."
|
|
|
|