|
The Enter key will be sent to your button only if your button return DLGC_DEFPUSHBUTTON as response to the WM_GETDLGCODE message. When the owner style is set, this value will not be returned by the button. So the solution is to overide th WM_GETDLGCODE message of the button and return the DLGC_DEFPUSHBUTTON in addition to the default values.
like
return CButton::OnGetDlgCode()|DLGC_DEFPUSHBUTTON ;
|
|
|
|
|
But if I return DLGC_DEFPUSHBUTTON, I can not owner draw its background. Do you have any other better way to handle it.
Thanks a lot.
|
|
|
|
|
ok ok i missed one point. In addition to the above thing handle the BN_SETSTYLE message( you have to manully add it message map. Class wizrad will not show this message ).
in the mesasge map
ON_MESSAGE( BM_SETSTYLE, OnSetStyle )
The function
LRESULT ButtonEx::OnSetStyle( WPARAM wParam_i, LPARAM lParam_i )<br />
{<br />
const int ODDBTN_BS_TYPEMASK = 0x0000000FL;<br />
return DefWindowProc( BM_SETSTYLE, ( wParam_i & ~ODDBTN_BS_TYPEMASK ) | BS_OWNERDRAW, lParam_i );<br />
}
|
|
|
|
|
Ok. Now it works. But I feel a little wonder, what you need to write:
( wParam_i & ~ODDBTN_BS_TYPEMASK ) | BS_OWNERDRAW
why not
BS_OWNERDRAW
or
wParam_i | BS_OWNERDRAW
I still doesn't very clear how to handle edit control's ENTER event.When I set edit's style "multiline", it will accept ENTER event and do the parent Dialog's OnOK() function. But I only want it jump to the next tabstop control or find some function that I can handle the ENTER event.
Thanks for reply.
-- modified at 4:46 Monday 4th June, 2007
|
|
|
|
|
Peter, Chan wrote: But I only want it jump to the next tabstop control or find some function that I can handle the ENTER event
You can handle this in the PreTranslateMesage(). Search for PreTranslateMesage in the message board. You can find many solutions.
|
|
|
|
|
|
Hi Forum,
I need to retrieve the time at which a message was posted (or at least, when it was first handled by the Windows messaging system) in a Callback function set through MFC's MESSAGE_MAP.
Briefly:
- I have a library sending messages (but I have *no control* over that library, I must use it as it is);
- My class registers a callback for this kind of message through MFC's MESSAGE_MAP;
- This class would like to know when the message was posted.
I know the Windows' GetMessage() function gets a MSG struct with this information, but it's removed when sent to the callback :/
And since I use MFC, I can't call GetMessage() myself, can I ?
And as said above, I can't modify the library to add this information as a parameter (for example in the WPARAM, which is transmitted to the callback).
So, is there another way to retrieve the time of arrival of the messages my class is supposed to handle ?
Thanks a lot,
Julien
|
|
|
|
|
CWnd::GetCurrentMessage
This function returns a pointer to the current MSG structure being processed [by a window]. Call it inside a message handler function only.
--
=====
Arman
|
|
|
|
|
hi, i am trying to retrieve domain and user name by the following code
#include "windows.h"
LPTSTR lpszSystemInfo;
DWORD cchBuff = BUFSIZE;
TCHAR tchBuffer[bufsize];
lpszSystemInfo = tchBuffer;
if( GetComputerName(lpszSystemInfo, &cchBuff) )
m_machineName = _bstr_t(lpszSystemInfo);
cchBuff = BUFSIZE;
if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
m_domain = _bstr_t(lpszSystemInfo);
cchBuff = BUFSIZE;
if( GetUserName(lpszSystemInfo, &cchBuff) )
m_osUsername = _bstr_t(lpszSystemInfo);
This is a part of the code.
When i compile it, I get the following error:
error C2065: 'GetComputerNameEx' : undeclared identifier
error C2065: 'ComputerNameDnsDomain' : undeclared identifier
Can anyone help me solve it?
Moonis
-- modified at 21:39 Sunday 3rd June, 2007
|
|
|
|
|
Please put any code inside < pre>< /pre> tag to view it correctly.
Before including <windows.h> you should define _WIN32_WINNT greater than or equal to 0x500;
#define _WIN32_WINNT 0x0500
#include <windows.h>
--
=====
Arman
|
|
|
|
|
Hi,
I did the above settings to enable the macro but the problem still persists. My modified code is here:
#define _WIN32_WINNT 0x0500
#include "windows.h"
#include "stdio.h"
#include "iostream.h"
#include "tchar.h"
int main()
{
LPTSTR lpszSystemInfo;
DWORD cchBuff=sizeof(lpszSystemInfo);
if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
cout<<"Domain Name is : "<<cchBuff<<endl;
char acUserName[100];
DWORD nUserName = sizeof(acUserName);
if (GetUserName(acUserName, &nUserName)) {
cout << "User name is " << acUserName << "." << endl;
}
else {
cerr << "Failed to lookup user name, error code " <<
GetLastError() << "." << endl;
}
return 0;
}
I am new to VC++ programming so please point out any other errors if there are.
Moonis
|
|
|
|
|
Which version of platform SDK are you using?If not download the latest platform SDK from the microsoft site.
|
|
|
|
|
Hi,
I am using MS Visual C++ 6.0 running on Windows 2000 Server.
Is the problem related to the above version that i am running?
Moonis
|
|
|
|
|
declaration of this file dosent come with the vc 6. You neeed to download the latest platform SDK
|
|
|
|
|
You have to define the _WIN32_WINNT version to 0x0500 or greater. for this Take
project settings->c++->Preprocessor definition.
In that edit box add _WIN32_WINNT=0x0500
|
|
|
|
|
Hi,
In the msdn documentation for GetComputerNameEx it is given
"To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0500 or later"
have to confirmed it and it required to include windows.h
|
|
|
|
|
hai,
i want to create a dll that loads bitmap.i am a beginner to a dll.anyone please help me. i read http://www.codeproject.com/vbscript/LoadBMPFromDLL.asp".
but they are not giving the vc++ code part .Any please give any basic idea
|
|
|
|
|
What's giving you trouble - loading a bitmap or creating a DLL?
Loading a bitmap is the same in a DLL as in an EXE.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
But why you want to load bitmaps of a dll?
|
|
|
|
|
I am running five instances of an exe simultaneously. will there be any memory sharing or memory over writings. Suppose i have a strcuture in the code . when i am running five instances will the memory allocated for that structure will be different for each instance? i am not not using "new" operator. i am just taking an object for the structure.
ex:
struct sample{
CString name;
};
sample s;
Anil Jillella
|
|
|
|
|
anilkrupakar wrote: I am running five instances of an exe simultaneously. will there be any memory sharing or memory over writings.
No.
anilkrupakar wrote: Suppose i have a strcuture i the code . when i am running five instances will memory allocated for that structure will be different?
Yes.
You have to explicitely handle shared memory if you need it.
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.
|
|
|
|
|
Hi all,
Is there a way to allow only a specified program to load a dll.
For example: There is a dll called "test.dll" and I don't want other programs loading it except "test.exe". Is there a way to check the caller in dll main function and denide access if the caller is not authorized.
thanks.
Arun
|
|
|
|
|
Hi Toxcct,
toxcct wrote: that's stupid...
You're not playing well with others in the sandbox...
I've received the same sort of answers before (from PhD's no less). It made no sense because there was no context of the problem domain. What do you know of the OP's problem domain or project requirements? I did not see it in the original post.
Perhaps the OP has developed an RSA Integer Factorization algorithm he wants to use in his work only: the first being his RSA modulous generation program (to test that n = p * q ), and a second to factor other's moduli. In this case he may not want to share the functionality - for example, the NSA[^] has threatened him with bodily harm.
Finally, what if the DLL is actually a resource of custom graphics or messages...
Jeff
|
|
|
|
|
Hi,
I am not sure whether we can deny access to dll using system control.
But you can do that in your way.
For instance if your dll export a function
CYourDllClass *CreateInstance();
and the object it returns is needed for further processing.
you can do this
CYourDllClass *CreateInstance(yourSecurityKey)
{
if (Authorised(yourSecurityKey))
{
return new CYourDllClass();
}
else
{
return NULL;
}
}
Best Regards
-- modified at 6:42 Friday 1st June, 2007
|
|
|
|
|