|
I just discover the ShowScrollBar(), it does just what I want
|
|
|
|
|
Hi Everyone !
Do anyone know how i can convert a CString to a TCHAR[1024] ??
Please help !!!
MFG
RedDragon2kx
Unix and C are the ultimate computer viruses.
Visit me: www.programming.info.ms
|
|
|
|
|
CString ?
so you are using mfc?
i am, and use CString::GetBuffer(), followed by CString::ReleaseBuffer();
obviously you have to do something useful with the array (like doing a strcpy() ) as direct changes to it will modify the CString;
also when you call ReleaseBuffer() it realloc's the internal buffer of the CString ie: your array, unless copied, points to undefined memory!
i'm sure there's an easier way, but if you need to get the proj up and running NOW, there it is.
Consistency is the last refuge of the unimaginative.
Oscar Wilde
|
|
|
|
|
It is unnecessary to use GetBuffer() and ReleaseBuffer() when a read-only copy of the buffer is all that's required. For example:
CString str;
TCHAR tch[1024];
strcpy(tch, str);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
Hi,
Can any one explain me how I can...
1)copy a bitmap(CBitmap object) into the clipboard in MFC?
And
2)load a .bmp file into a CBitmap Object?
Please help.
|
|
|
|
|
Can use the following code 4 loading a bitmap
CBitmap bm;
bm.LoadBitmap(IDB_BITMAP);
CDC *pDC = GetDC();
pDC->DrawState(CPoint(70,70),CSize(216,232),bm,NULL);
pDC->ReleaseAttribDC();
|
|
|
|
|
Hello All,
I am trying to make a game for assignment and need to communicate between 2 processes.
I am creating memory map and sharing memory between 2 processes....
After I copy the memory on memory map from the main process, I need to inform the child process to start reading the memory..how can i do this?
is SendMessage a proper way to do it? if yes how do i do this, I just need to find a way to send message from the main process and receive messege in the child process....
any help will be greatly appreciated
Thank you
|
|
|
|
|
Are you talking 2 different applications or 2 different threads?
For applications you need to implement some form of interprocess communication (ipc) in which there are various tried and tested methods, each with their pros and cons. I suggest you read up on these before deciding on an appropriate one.
For threads, your child thread will need to process messages. Then you should use PostThreadMessage()
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hi,
Thanks for your reply, I am talking about 2 different applications...
for IPC i have already created memory map and i can read data from both application....but the problem is how do i inform processes when they can read data...
|
|
|
|
|
You may want to look at the WM_COPYDATA message. This would be sufficient for notification purposes.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Thank you,
I will look into it
I appreciate your help
|
|
|
|
|
hello all,
what is lvalue error?. is there Rvalue error too?. if yes plz give me some explanation about these 2 error types.
Thanking u all.
ComputerNewton
|
|
|
|
|
I can only assume you mean when the compiler is expecting an l-value on the left-hand side of an assignment:
i=10; is fine so long as i was not defined as a constant.
More obviously:
10=3; will give you an l-value error because 10 is not an l-value and therefore cannot be assigned to anything else.
10 is 10, and cannot be anything else!
I hope this helps,
Zoltan
|
|
|
|
|
Can I group function (method) within Struct in ANSI C?
I constantly listen people talking about it. Many have
stated that it can be done.
If it can be done, is it recommended to do so?
Thanks
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
|
Thanks for your reply.
I did mean function pointers within Stuct. I mean function within
Struct. Some people are stating that Object-oriented can be done
in ANSI C. I just don't think so. But I'm not really sure.
Can it be done?
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
Literal reply : No.
Assumed reply : Yes.
ANSI C is not an OO language.
The concept of excapsulation is not supported.
A pure C compiler would fail to compile a struct with a method.
There are few, if any, pure C compilers around in use anymore.
C++ made an effort to be backwards compatible with C.
In doing so it made some modifictions to some of the C syntax to make it fit better with the C++ paradigm.
One such change was to give struct the same abilities as class. That is, struct definitions can include methods.
The only real difference, in C++, between struct and class is the default access control.
struct : by default everything is public.
class : by default everything is private.
So, a C++ compiler would have no problem with a struct with a method.
As for being recommended ... a topic sure to start a religous war.
Personally i use struct for simple records.
I will only provide constructor, reset/init methods.
For me, seeing a struct is an indicator that the object is simple/dumb.
I use classes for all other records.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
it would probably be a good idea to delete one of these posts no need for 2
|
|
|
|
|
I have a template class inside which I wish to embed some static constants to speed up some time-critical code. Consider this:
template <class T, int I> class X<br />
{<br />
private:<br />
static const icopy = i;<br />
static const iminus1 = i-1;<br />
static const itimes8 = i<<3;<br />
int array[I];<br />
public:<br />
(..)<br />
};
I is assigned by the code using the template to the size of T, which is fine when the compiler uses it to create the array with num elements equal to I.
However, all of the static constants appear to be getting initialised to 1, even when I is explicitly set to 4 or 8.
I wish to make these constants static in order to reduce memory overhead, therefore a solution to this problem is kinda essential to me? Am I mis-using the language? Or is it an example of VS.Net 2003's C++ compiler's non-conformance?
Please help!
Thanks in advance...
|
|
|
|
|
I and i are different variables entirely. And making them static probably won't reduce memory usage. The values will all be known at compile time, so the compiler will be able to directly insert the values (unless you take the address of iminus1 or one of the other members).
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Ford, what's this fish doing in my ear?
|
|
|
|
|
Hi Mike,
Thank you for your reply -
Michael Dunn wrote:
I and i are different variables entirely. And making them static probably won't reduce memory usage
I was being stupid in my code example - I am trying to use the template argument I to assign my static constants in order to reduce computational overhead in any functions that need to use them. I accidentally put i instead because I was half asleep when I posted the question!
In theory, therefore, if I use the template argument, which will be a compile-time constant of, say, 4, to calculate the other constants, how can icopy be getting set to 1 and not 4?
Thanks
|
|
|
|
|
Unfortunately, I'm not seeing the problem you are. Here's the code I tested on VC 7.1:
#include <iostream>
#include <tchar.h>
using namespace std;
template <class T, int I> class X
{
public:
X() {}
static const icopy = I;
static const iminus1 = I-1;
static const itimes8 = I<<3;
int array[I];
};
int _tmain(int argc, _TCHAR* argv[])
{
X<int, sizeof(int)> x1;
cout << "x1.icopy = " << x1.icopy
<< "\nx1.iminus1 = " << x1.iminus1
<< "\nx1.itimes8 = " << x1.itimes8 << '\n';
return 0;
} Output:
x1.icopy = 4
x1.iminus1 = 3
x1.itimes8 = 32
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
|
|
|
|
|
Mike,
Sometimes, it just helps when someone forces you to look at your code again eh!!? Whilst we've been discussing this, I converted the template class so that it simply used standard members and discovered that there was a general error in some of my logic that was making it appear that these static constants were getting initialised to 1. Of course, however, they weren't - as you've demonstrated and I've just verified.
What didn't help - and I'm not going mad on this one - is that the VC++ debugger picks up these values at run-time as 1 (perhaps understandably, since their values are dependent on the template args), regardless of what value they actually have, therefore I had just assumed that the compiler was stupid, and not me. I should have remembered that the console project is my friend when it comes to debugging values.
Thanks to your help, I have now converted it back to static constants and have received a fifth of a second speed increase over the course of 250,000 operations that will use this class - not much, but enough for me to be happy !
Thanks very much for your help,
Zoltan
I'm not as evil as my name suggests
|
|
|
|
|
Great, I'm glad it worked out for you. Funny thing about the debugger, you could report that to MS so they fix it for Whidbey.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
Actual sign at the laundromat I go to: "No tinting or dying."
"Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer."
-- Michael P. Butler in the Lounge
|
|
|
|