|
Finding the sum of the numbers between two integers can be done as follows:
int i = x + 1; // we start counting 1 higher then x
// or make this i = x if you want to include x
int sum = 0;
while (i < y) { // repeat while we haven't reached y
// or make this i<=y if you want to include y
sum = sum + i;
i++;
}
voila.
or shorter:
int sum = 0;
for (int i=x+1;i
|
|
|
|
|
I have the following class:
class BaseClass {<br />
static char* wp;<br />
<br />
void Dynamic(char* s) {<br />
this->wp = s;<br />
}<br />
}
and a derivative:
class Derived : public BaseClass {<br />
}
Basically, what I want to accomplish is this: I want to reference the static member wp of the derived class in the inhereted function and reference the BaseClass member in the Baseclass function
so..
BaseClass *bc = new BaseClass();<br />
Derived *d = new Derived();<br />
<br />
bc->Dynamic("something");<br />
d->Dynamic("something else");
After this code, I want bc::wp != d::wp, but alas, bc::wp == d::wp == "something else". I would LIKE to have bc::wp == "something" and d::wp == "something else".
Anybody have any clues as to how I might realise this? And yes I do realise I could make them non-static, but I am interested in a way of doing this... if at all possible.
|
|
|
|
|
If you want the derived class to have its own, separate copy of the static member,
you have to declare it in the derived class. Then, you also have to implement Dynamic() in the derived class so it refers to the derived class' static member and not the base class' static member.
|
|
|
|
|
Can I create a CWnd* class from an DLL that is loaded at runtime and the use it.
Like this.
I have a tabview in my program that takes CWnd* objects.
And say that the user select something and then a DLL is lunched ( a plugin )
And all Plugin DLLs have a function call CreateObject(). It calls it and returns a CWnd* object.
The main program don’t know anything about the object except that it’s a CWnd* object
Now.
Can I just take this object and threat it as any other object ?
What restriction are they?
Do I need to do some special stuff to make it work?
What I understand is that I need to let the DLL also take care of
the deleting of the object, since it create it. Is that correct ?
/Mathias
|
|
|
|
|
I have a object that I created that is derived from CWnd. In my SDI
application with a CFormView, I have created the object. (Draws a box on the
form) Now I would like the object to handle the left mouse down event. I
added the left mouse button down event to my object. But how do I ??? so
that my object receives the left mouse down event when a user clicks on the
object? (box)
Thanks
|
|
|
|
|
MFC sure can be confusing.........
When would you use OnPaint() instead of OnDraw() for drawing in an MFC application?
Should on be used in a dialog and the other used in a doc/view app?
|
|
|
|
|
Well, OnPaint() calls OnDraw() . I think OnDraw() is specific to views, whereas OnPaint() is for repainting in general.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I want to change the background color of the Combo box with drop down style.
I tried doing it using WM_CTLCOLOR message code. however it works for all edit boxes and combo boxes of style list box and not for the drop down.
kindly advise on this.
|
|
|
|
|
How i can convert a CString to LPCTSTR?
I can't found an easy solution for this. Please give a help.
Thank's bros.
|
|
|
|
|
Nothing easier than that:
CString cstr;<br />
LPCTSTR lpString = (LPCTSTR)cstr;
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
No need to cast:
LPCTSTR lpString = cstr;
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
You don't need to convert anything, CString has an implicit LPCTSTR cast. If a function takes a const char* as parameter, simply take your CString.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
For unicode you better use the following
CString cstr;<br />
char * myString = (char *) (LPCTSTR) (cstr);
|
|
|
|
|
|
|
That is so wrong in so many ways.
First off, if it is a UNICODE build, then you will end up with a pointer to data such as.
0x65 0x00 0x66 0x00 0x97 0x00
To convert from a T string to a const char string, use the following macro:
T2CA (temp)
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
This is just wrong, whether UNICODE is used or not. If you need me to explain, let me know. Now it's quittin' time!
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
NO. Simply casting an LPCTSTR to a char * simply converts the pointer, not the characters. You must convert the characters, which requires using something like WideCharToMultiByte .
Software Zen: delete this;
|
|
|
|
|
XP saves all settings in binary files
located in windows\\system32\\config right?
i looking for some way to read these files?
i want to access registry from another os
|
|
|
|
|
If the other OS is Windows-based, you can use RegConnectRegistry() .
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
It is linux. so i need some code to do id
without windows API
|
|
|
|
|
Well, I don't know the format of any of the files that comprise the registry, so you may have a bit of work ahead of you.
Good luck.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Have you considered Winelib[^]? It may provide the Win32 functions you're looking for.
Otherwise, you might need to make your own limited version of the Remote Registry service to run on the Windows box.
- Mike
|
|
|
|
|
|
Hi,
I am nearing the completion of my app (and a big thank you to everyone here who has helped me so far - I've received a lot of help and do really appreciate it). I am currently working on saving project files, but there is one aspect of my app I have no idea how to go about saving, and would be very grateful for some advice.
Part of my app works a little like Windows Explorer. On the left there is a folder tree and on the right a file list. The user can create a file tree containing a number of files, and upon hitting a "Build" button, the folder tree he or she has defined is created on disk, and the specified files copied into these folders (you may wonder what the advantage of this method is over just letting my user do all this in Windows Explorer, but trust me that this makes sense in the context of the rest of my app - for instance, the paths of the folders are stored as command-line parameters etc).
So far, so good. However, when my user goes to save a project, the project must save the directory tree that he has created, and it is this that I do not know how to achieve. The directory tree is just a tree view - ie. a sequence of HTREEITEMs. On saving a project, the app needs to look at the tree view and save the structure, which can of course consist of an unlimited number of HTREEITEMS organised in any order with various properties. Upon loading a project, the app needs to be able to reconstruct this tree view just as it has been saved.
I thought of using a string array to hold the paths of the folders and try to reconstruct them from the paths, and using a number array to hold the properties, but this seems a very long-winded way of doing it.
Can anybody suggest a good method of dealing with this? I'm using the straight Windows API with _no_ MFC, but that shouldn't make too much difference as I'm not asking for code so much as for ideas about how one goes about storing information about something as complex and arbitrary as a customisable tree view.
Many thanks for any help,
KB
|
|
|
|