|
and by the way, disabling Alt+Enter, Alt+tab, Ctrl+Escape, when the app is fullscreen. I know the W98 screensaver trick, I tried several NT tricks but none of them apply to Windows XP. I am searching for C/C++ coding.
Thank you.
|
|
|
|
|
If you want to do programatically (I don't know any other way to do it , but I'm novice...) you must install a system wide keyboard hook.
In that hook (that must be placed in a DLL) you can handle all the key presses (except the mytical Ctrl+Alt+Del that must be handled in a GINA.DLL).
If you want to install that hook from the beggining you can install an autostart service that activates it.
Hope this helps.
|
|
|
|
|
Hello.
I need to implement a template class that would have the same functionality as std::vector plus several other functions - practically extending vector. The easiest way to accomplish this would be to publicly derive this class from vector, but from everything I know this is considered a bad thing because vector has no virtual functions, and the relation between my class and vector is "implemented in terms of" rather than "is kind of". Any advice?
|
|
|
|
|
I know for a fact that std::string has no virtual destructor to stop people from deriving from it, std::vector sounds the same, if by 'no virtual functions' you also mean no virtual destructor. You need to contain a vector and then expose the methods you want to use in your own class, adding whatever you're after. Or consider the nature of your additions, perhaps they should be function objects that rely on random access iterators ( if necessary ).
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Christian Graus wrote:
You need to contain a vector and then expose the methods you want to use in your own class, adding whatever you're after.
Yes, I thought about it. However, I need "everything" from std::vector, and it would be tedious to rewrite all public methods from it. Public inheritance would allow me to reuse std::vector's interface and add my additional functions quickly. Now what practical implications would be? I mean, who would use polymorfism with std::vector?
|
|
|
|
|
So long as you don't introduce any data it should work just fine to derive from std::vector.
The only time (I can come to think of right now) when you need a virtual destructor, is when subclasses also contain data (that would otherwise not be destructed when deleting the subclass using a pointer-to-base).
|
|
|
|
|
Thanks. I think you are right.
|
|
|
|
|
Why not have a class with std::vector as a public member, and some interface functions for the other stuff you want to do? Or will that somehow defeat the purpose?
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
It would break a lot of existing code. This template class (which I need to reimplement) must have exactly the same interface as std::vector plus several extra functions.
|
|
|
|
|
I want to change the screen saver without any message to user? Can u help me out?
Mahesh
|
|
|
|
|
I've looked into this with no success....I'm not sure if it's possible....
|
|
|
|
|
Hello,
is the memory allocated by the GlobalAlloc function really global? Can different processes access the same memory block allocated by GlobalAlloc?
Thanks
-Dominik
|
|
|
|
|
No. Memory allocated by GlobalAlloc is not visible to other process. If you want to share memory across process, i sugest that you use memory mapped files.
Also, MSDN state that GlobalAlloc is not the preferred way to allocate memory. Try the heap memory function instead (HeapAlloc, HeapFree, ect,ect).
|
|
|
|
|
Ok, I will use memory mapped files.
Thank you!
-Dominik
|
|
|
|
|
When you call ::CreateFileMapping with (HANDLE) LongToHandle(-1) as the first parameter, PAGE_READWRITE as the protection and a name, which is how other applications will access it by calling OpenFileMapping . If the creator will be in one set of permissions (like a service logged in as an administrator) and the other application will have lower permissions, you'll need to create and use SECURITY_ATTRIBUTES (you can create a NULL security attribute which essentially grants global rights to the memory.)
|
|
|
|
|
Hi,
I have a problem splitting up a string.
I have a thread which will send a string to my main thread by posting a message.
I therefore create my string
<br />
CString *s = new CString();<br />
s->Format("%s#@@#%s", _T("Error"), _T("ErrorMessage"));<br />
PostMessage(UWM_SENDSTRING, (WPARAM)i, (LPARAM)s);<br />
The code is successfully received by my function.
However, here is where it goes wrong.
<br />
LRESULT CMyView::OnSendString(WPARAM wparam, LPARAM lparam)<br />
{<br />
CString *s = (CString*)lparam;<br />
TRACE0(*s);
<br />
int pos = s->Find(_T("#@@#"));
TRACE0(s->Left(pos));
TRACE0(s->Right(s->GetLength()-(pos+4)));
<br />
delete s;<br />
<br />
<br />
So basically when I show the string, compute a position or show the length of *s everything is fine.
When I just want a part of the string, the first or last, I get a lot of crap or the program just crashes.
When I do all of that splitting in a normal procedure whit normal CString (not dynamically allocated), I get the results thaat I want, namely he part before #@@# and the part after that.
Any ideas how I can let this Left/Right splitting thing work on dynamic CStrings?
tia
Wim
|
|
|
|
|
Try setting a watchpoint (breakpoint on a data address) on s after you create it, and before the PostMessage call. It sounds like something else is modifying it. Also, have you single stepped through the OnSendString function, and watched the contents of s in the Watch window?
Software Zen: delete this;
|
|
|
|
|
I don't think what you are doing is allowed, in effect posting a class, I am sure someone will confirm/deny that, so why not do:-
CString *s = new CString();<br />
s->Format("%s#@@#%s", _T("Error"), _T("ErrorMessage"));<br />
TCHAR *sz = new char[s.GetLength() + 1);<br />
strcpy(sz, s->GetBuffer(0));<br />
PostMessage(UWM_SENDSTRING, (WPARAM)i, (LPARAM)sz);
Note the code is not 100% correct, e.g. strcpy should not be used if you are using UNICODE
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
This is probablya bit late (its a public holiday down here in Australia, but I got suckered into coming into the office anyway)
anyway, see this link for an explanation and working code on posting CStrings (look for "Passing Pointers in Messages") - Note well one of Joe's comments "However, if you ever plan to use PostMessage to pass a pointer to an object, then you are constrained to always use a static or heap-based object"
http://www.pgh.net/~newcomer/messages.htm[^]
Hope this helps ...
'G' <- Grinch !!!
|
|
|
|
|
Hi Garth,
Thanks for the advice.
Strangely enough, the piece of code I posted comes from another essay of Mr. Newcomer I read about threads[^].
There was a reference to the article you mentioned. So probably I missed something reading the articles, or I'm just a bad cut&paste person.
I will read these articles again tonight and see if I missed something, else I just send 2 messages (errorcode and errormessage) as it seems to work (Using watch variables) if I don't tamper around with the strings.
Thanks and enjoy your holiday
Wim
|
|
|
|
|
Wim Jans wrote:
) if I don't tamper around with the strings
Hi Wim - I think it comes down to that particular phrase ... when I worked in San Diego recently I worked on a project that had to modify a CString .. yuck !!! there's a particular set of hoops you have to go through - something like CString.ReleaseBuffer().. I think this is also discussed by Joe Newcomer, under his MVP tips 'CString Management' ... its still a pain in the rear though
good luck !
|
|
|
|
|
i am using SDI MFC application. i am trying to generate many modeless dialogs in child style at the same time to display drawen charts.i use it in child styleso i can apply cascadewindows(....) function. but that leads that the dialogs is misdrawed.it's fine in pop style but i can't make it cascaded or tiled. how can i do so??????????
|
|
|
|
|
Hi, everyone!
I have two samples on CRITICAL_SECTION, I want to know
the difference between them.
Sample 1:
--------
CRITICAL_SECTION cs;
EnterCriticalSection(&cs);
//code block1
LeaveCriticalSection(&cs);
EnterCriticalSection(&cs);
//code block2
LeaveCriticalSection(&cs);
--------
Sample 2:
--------
CRITICAL_SECTION cs1;
CRITICAL_SECTION cs2;
EnterCriticalSection(&cs1);
//code block1
LeaveCriticalSection(&cs1);
EnterCriticalSection(&cs2);
//code block2
LeaveCriticalSection(&cs2);
--------
I think in sample 1, code block 1 and code
block 2 can not be executed simultaneously.
But I sample 2, code block 1 and code
block 2 may be executed simultaneously.
Am I correct?
Thanks in advance,
George
|
|
|
|
|
George2 wrote:
CRITICAL_SECTION cs1;
CRITICAL_SECTION cs2;
EnterCriticalSection(&cs1);
//code block1
LeaveCriticalSection(&cs1);
EnterCriticalSection(&cs2);
//code block2
LeaveCriticalSection(&cs2);
hi george
EnterCriticalSection() is a blocking function, that will only returns when the calling thread get the ownership.your examle code doesnot excecuet simultaniosly
If u wanna that
use TryEnterCriticalSection() API, that will returns immediatly
~CodeTheDreams~
|
|
|
|
|
Thanks, Renjith pal!
In such case,
1. Thread 1 enters code block 2, before it leaves code block 2,
for some reason, it sleeps;
2. Thread 2 enters code block 1;
3. for some reason, thread 1 wakes up and run code block 2,
So in my case, code block 1 and code block 2 could run simultaneously.
Am I correct? But in my sample 1, such case would not happen.
I am not sure about my two samples, so I want to listen to others.
Thanks in advance,
George
|
|
|
|