|
Thanks Mark!
You mean call this API twice? I showed my understanding of your points in the following pseudo code. Any comments? Does it what you mean?
int size;
GetComputerNameEx(
__in COMPUTER_NAME_FORMAT NameType,
NULL,
&size
);
buffer = new char[size+1];
GetComputerNameEx(
__in COMPUTER_NAME_FORMAT NameType,
buffer,
&size
);
regards,
George
|
|
|
|
|
George_George wrote: You mean call this API twice?
Yes.
You may want to increment the size variable before the second call...
int size = 0;
GetComputerNameEx(
__in COMPUTER_NAME_FORMAT NameType,
NULL,
&size
);
size++;
buffer = new char[size];
GetComputerNameEx(
__in COMPUTER_NAME_FORMAT NameType,
buffer,
&size
);
Many APIs were designed to be called that way.
If you absolutely must use a static buffer length, in my experience,
a buffer size of 260 (MAX_PATH) has always been large enough.
Doing it as shown above is the safe, correct way, however.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi,
I am using VLC plugin 2 Active X control in vc++ sample application.
I can able to see live video, using CVLCPlaylist.add() method call.
How to take snapshot?
Any help ?
|
|
|
|
|
printscreen button
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Hi,
Thanks for your reply.
how to set the snapshot path?
is there any default path for snapshot?
I tried your suggestion for taking snapshot.
But it is not working.
Is there any possibility to use CVLCVideo::takeSnapshot() ?
|
|
|
|
|
I dont know if this is the right forum to post this query
i wanted to know if we can achieve inheritance and encapsulation in C.
|
|
|
|
|
With some effort, you can mimic inheritance.
Use of structs effectively gets you encapsulation.
|
|
|
|
|
a little more explanation will be of great help.
|
|
|
|
|
struct base<br />
{<br />
};<br />
<br />
struct derived : public base<br />
{<br />
};
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
?
struct derived : public base
that is not C
|
|
|
|
|
I see that I failed to see that the OP wanted a solution in C.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Why don't you use C++ , instead?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
that is a good qusestion.. i can certainly use C++. but its just the curiosity to know how it can be done. i actually saw in a forum that inheritance can be acheived in c but there was no practical example available in the forum, there was only some explanations that was not satisfactory. so wanted to know more about it . if you could provide that would be great.
|
|
|
|
|
Just read this - Object Oriented Programming in C[^]. Implementing OOP behavior in C is not tough because cfront - the first C++ compiler does compilation by translating C++ source to C and then compile it. If you are insterested, have a look at the cfront source from here[^].
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi, I've created an owner draw Menu and i wanted to get the text and the shortcut key seperately. Any idea??
By calling below code, it will get both text and shortcut key and put inside a string.
COwnerMenu OwnerMenu; //this is inherit from CMenu
OwnerMenuPointer->GetMenuString(i, str, MF_BYPOSITION);
I tried to seperate it by searching "Ctrl+"
But as the shortcut key might not started with Ctrl+, so i cant use this method..
Can i get the shortcut key and also the text seperately by using the pointer "OwnerMenuPointer" ??
I've search through net and I cant find any solution
Any help would be appreciated.
Regards,
KH
good
|
|
|
|
|
The shortcut text is separated from the menu item text by a tab character. Just search for \t within the menu string and split it at that point.
|
|
|
|
|
OH THANKS!!!
IT WORKS !!
good
|
|
|
|
|
How are you defining the menu items? Usually, you define a shortcut key for a menu item using \t and Windows displays the shortcut on the right hand side of the menu. For example, in the resource editor, you would define New as New\tCtrl+N
|
|
|
|
|
You should also look at this article:
http://www.codeproject.com/KB/menus/newmenuxpstyle.aspx[^]
I helped the author add code to parse the accelerotor table to get the short cut keys, cutting out the need to write them in the menu initially. This also lets you have changeable keys in your software.
And it's a super article before I put my nose in...
Iain.
|
|
|
|
|
oh thanks !!
Its a great article ^^
good
|
|
|
|
|
When the user begins editing an item label in a list control, I'd like to select a portion of the text in the edit control. I'm using MFC and currently, I'm calling GetEditControl() in the LVN_BEGINLABELEDIT handler and then using SetSel() to set the selection in the edit control. This works as expected under Vista, but under XP, the code seems to have no effect and nothing is selected. Has anyone come across this behaviour before? Any help towards solving this problem is greatly appreciated.
|
|
|
|
|
Just an idea, try posting the EM_SETSEL[^] message to the edit instead of calling SetSel() on it directly in the message handler and see if it changes anything.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Wonderful, it works! I guess that XP resets the selection after the LVN_BEGINLABELEDIT handler returns, so posting the message did the trick.
|
|
|
|
|
Good old PostMessage, it helped me out a few times too. Maybe we should send flowers as a thank, or better, post flowers.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|