|
I use only a line, but I like to disable the Enter key.
|
|
|
|
|
Overload the OnOk message handler , do next :
void CYourDlg::OnOK()
{
//CDialog::OnOK();
}
the problem is that OK is set to default button and when you press Enter , automatically OnOk event handler is called.
Note that if you have only deleted the Ok button ,without doing what i wrote above , it does not solve the problem.
In this case you will have to drop any button make it "Default Button" and "Invisible", .
m0n0
|
|
|
|
|
Giorgi Moniava wrote:
n this case you will have to drop any button make it "Default Button" and "Invisible"
bad coding...
moreover, if you have to change the default button programatically (when the code executes), how will you do ? - i doublt you can like this...
use CDialog::SetDefID() instead into OnInitDialog()
CDialog::SetDefID()
this->SetDefID(IDC_BUTTON1);
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Can you tell me the better way of doing this ??
when the OK button is already deleted
m0n0
|
|
|
|
|
Giorgi Moniava wrote:
Can you tell me the better way of doing this ??
when the OK button is already deleted
already posted, re-read my message
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
the enter key functions as a button-press.
Probably the OnOk of your dialog is being called when you press enter, and the default action of OnOk is to close the dialog.
What you can do is capture the VK_RETURN event in your edit control and e.g. do nothing or translate it to VK_TAB...
You could also capture the VK_RETURN in your dialog offcourse and not have it execute the default behaviour.
Hope this gets you along,
Davy
|
|
|
|
|
Hi,
My application calls the SearchPath() API in a method which gets the version info of a file. On execution, the UNICODE debug version of the application always crashes. The error shown is 'Unhandled exception in MyAppl.exe (NTDLL.DLL): 0xC0000005: Access Violation'. The MBCS/UNICODE Release build of the application works fine and also the MBCS debug build.
<br />
DI_STATUS getFileVersionInfo(TCHAR * FileName)<br />
{<br />
TCHAR pathBuffer[MAX_PATH];<br />
struct VS_FIXEDFILEINFO <br />
{ <br />
DWORD dwSignature; <br />
DWORD dwStrucVersion; <br />
DWORD dwFileVersionMS; <br />
DWORD dwFileVersionLS; <br />
DWORD dwProductVersionMS; <br />
DWORD dwProductVersionLS; <br />
DWORD dwFileFlagsMask; <br />
DWORD dwFileFlags; <br />
DWORD dwFileOS; <br />
DWORD dwFileType; <br />
DWORD dwFileSubtype; <br />
DWORD dwFileDateMS; <br />
DWORD dwFileDateLS; <br />
} *lpFixedFileInfo; <br />
<br />
TCHAR fileInfoBuffer[2048];<br />
UINT32 VersionInfoSize;<br />
if (SearchPath(NULL, FileName, NULL, sizeof(pathBuffer), pathBuffer, NULL) > 0)<br />
{<br />
LogMsg(_T(" SearchPath: %s\n"), pathBuffer);<br />
}<br />
else<br />
{<br />
return(ERR_FILE_NOT_FOUND);<br />
}<br />
if ((VersionInfoSize = GetFileVersionInfoSize(FileName, 0)) > 0)<br />
{<br />
if (GetFileVersionInfo(FileName, NULL, VersionInfoSize, fileInfoBuffer) > 0)<br />
{<br />
VerQueryValue(fileInfoBuffer, TEXT("\\"), (LPVOID *)&lpFixedFileInfo, &VersionInfoSize);<br />
LogMsg(_T(" FileName : %s Version: %d.%d.%d.%d\n"),FileName,<br />
HIWORD(lpFixedFileInfo->dwFileVersionMS),<br />
LOWORD(lpFixedFileInfo->dwFileVersionMS),<br />
HIWORD(lpFixedFileInfo->dwFileVersionLS),<br />
LOWORD(lpFixedFileInfo->dwFileVersionLS));<br />
}<br />
else<br />
{<br />
return(DI_ERR_FILE_NOT_FOUND);<br />
}<br />
}<br />
else<br />
{<br />
return(ERR_FILE_NOT_FOUND);<br />
}<br />
return(DI_SUCCESS);<br />
}<br />
The function call is
TCHAR tmp[1024];
GetModuleFileName(NULL, tmp, sizeof(tmp));
getFileVersionInfo(tmp);
Am I missing out something here? I have Win2K OS. Please help.
Thanks,
Vini
|
|
|
|
|
Vinaya wrote:
GetModuleFileName(NULL, tmp, sizeof(tmp));
The third parameter is the number of characters, not the size of the buffer in bytes. You'll need to pass in 1024 to indicate there are 1024 characters (or sizeof(tmp)/sizeo(TCHAR) )
Vinaya wrote:
SearchPath(NULL, FileName, NULL, sizeof(pathBuffer), pathBuffer, NULL)
Ditto for the fourth parameter here.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Vinaya wrote:
if (SearchPath(NULL, FileName, NULL, sizeof(pathBuffer), pathBuffer, NULL) > 0)
Your exception is basically caused by the sizeof() input parameter of the function. This parameter required the number of characters that your string buffer holds. But the sizeof() function returns the number of bytes within the array. With a UNICODE program, each character occupies two bytes, so will therefore return twice the number required, resulting in a memory exception.
Try:
<br />
if (SearchPath(NULL, FileName, NULL, sizeof(pathBuffer)/sizeof(TCHAR), pathBuffer, NULL) > 0)
I Dream of Absolute Zero
|
|
|
|
|
Thanks a lot. That solved the problem.
Vini
|
|
|
|
|
Hi,
I've to capture the handle of the window, i knew the process id of the window, how to capture the window handle using the process id. Anyone pls provide me solution to the problem.
Thanks & Rgds
VVS
|
|
|
|
|
You could use EnumWindows .
In the EnumWindowsProc call GetWindowThreadProcessId and compare the process id with the one you have, if they match then that window belongs to the process in question.
You should be able to build up a list of all the windows that belong to the process.
|
|
|
|
|
Im using Visual c++ 6.0 with sql server 2000 database.
I create a new project with file database option and i select one of my big table.
Without writing another code when execute i have this error "Record set failed to open"
I don't understand, this is my code that was create automatically:
// articletestSet.h : interface of the CArticletestSet class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_ARTICLETESTSET_H__F9F350D0_CB82_11D9_B5A3_0001022AAD75__INCLUDED_)
#define AFX_ARTICLETESTSET_H__F9F350D0_CB82_11D9_B5A3_0001022AAD75__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CARTICLE
{
public:
CARTICLE()
{
memset( (void*)this, 0, sizeof(*this) );
};
wchar_t m_CODMAG[6];
wchar_t m_CODART[6];
wchar_t m_LIBELLE[26];
wchar_t m_libeltech[26];
wchar_t m_groupe[6];
wchar_t m_UNITE[3];
float m_QUANTITE;
float m_SEUILmag;
float m_PRIX_VENTE;
float m_PRIX_DOLLAR;
float m_prix_unitaire_dollar;
float m_pa_fc;
float m_LMH;
float m_LMB;
float m_encours;
wchar_t m_code_loca[6];
wchar_t m_shelf[16];
float m_aprix_unitaire_dollar;
wchar_t m_compte_charge[6];
ISequentialStream* m_image;
wchar_t m_code_arturi[6];
wchar_t m_NAME3[26];
wchar_t m_code_pe1[6];
wchar_t m_NAME4[26];
wchar_t m_code_pe2[6];
wchar_t m_name5[26];
wchar_t m_priorite[1];
wchar_t m_service[6];
wchar_t m_fournisseur[6];
wchar_t m_group2[6];
wchar_t m_group3[6];
wchar_t m_group4[6];
wchar_t m_deviseach[3];
wchar_t m_second_name[26];
wchar_t m_categorie[11];
wchar_t m_libcategorie[26];
BEGIN_COLUMN_MAP(CARTICLE)
COLUMN_ENTRY_TYPE(1, DBTYPE_WSTR, m_CODMAG)
COLUMN_ENTRY_TYPE(2, DBTYPE_WSTR, m_CODART)
COLUMN_ENTRY_TYPE(3, DBTYPE_WSTR, m_LIBELLE)
COLUMN_ENTRY_TYPE(4, DBTYPE_WSTR, m_libeltech)
COLUMN_ENTRY_TYPE(5, DBTYPE_WSTR, m_groupe)
COLUMN_ENTRY_TYPE(6, DBTYPE_WSTR, m_UNITE)
COLUMN_ENTRY_TYPE(7, DBTYPE_R4, m_QUANTITE)
COLUMN_ENTRY_TYPE(8, DBTYPE_R4, m_SEUILmag)
COLUMN_ENTRY_TYPE(9, DBTYPE_R4, m_PRIX_VENTE)
COLUMN_ENTRY_TYPE(10, DBTYPE_R4, m_PRIX_DOLLAR)
COLUMN_ENTRY_TYPE(11, DBTYPE_R4, m_prix_unitaire_dollar)
COLUMN_ENTRY_TYPE(12, DBTYPE_R4, m_pa_fc)
COLUMN_ENTRY_TYPE(13, DBTYPE_R4, m_LMH)
COLUMN_ENTRY_TYPE(14, DBTYPE_R4, m_LMB)
COLUMN_ENTRY_TYPE(15, DBTYPE_R4, m_encours)
COLUMN_ENTRY_TYPE(16, DBTYPE_WSTR, m_code_loca)
COLUMN_ENTRY_TYPE(17, DBTYPE_WSTR, m_shelf)
COLUMN_ENTRY_TYPE(18, DBTYPE_R4, m_aprix_unitaire_dollar)
COLUMN_ENTRY_TYPE(19, DBTYPE_WSTR, m_compte_charge)
BLOB_ENTRY(20, IID_ISequentialStream, STGM_READ, m_image)
COLUMN_ENTRY_TYPE(21, DBTYPE_WSTR, m_code_arturi)
COLUMN_ENTRY_TYPE(22, DBTYPE_WSTR, m_NAME3)
COLUMN_ENTRY_TYPE(23, DBTYPE_WSTR, m_code_pe1)
COLUMN_ENTRY_TYPE(24, DBTYPE_WSTR, m_NAME4)
COLUMN_ENTRY_TYPE(25, DBTYPE_WSTR, m_code_pe2)
COLUMN_ENTRY_TYPE(26, DBTYPE_WSTR, m_name5)
COLUMN_ENTRY_TYPE(27, DBTYPE_WSTR, m_priorite)
COLUMN_ENTRY_TYPE(28, DBTYPE_WSTR, m_service)
COLUMN_ENTRY_TYPE(29, DBTYPE_WSTR, m_fournisseur)
COLUMN_ENTRY_TYPE(30, DBTYPE_WSTR, m_group2)
COLUMN_ENTRY_TYPE(31, DBTYPE_WSTR, m_group3)
COLUMN_ENTRY_TYPE(32, DBTYPE_WSTR, m_group4)
COLUMN_ENTRY_TYPE(33, DBTYPE_WSTR, m_deviseach)
COLUMN_ENTRY_TYPE(34, DBTYPE_WSTR, m_second_name)
COLUMN_ENTRY_TYPE(35, DBTYPE_WSTR, m_categorie)
COLUMN_ENTRY_TYPE(36, DBTYPE_WSTR, m_libcategorie)
END_COLUMN_MAP()
};
class CArticletestSet : public CCommand<caccessor<carticle> >
{
public:
HRESULT Open()
{
CDataSource db;
CSession session;
HRESULT hr;
CDBPropSet dbinit(DBPROPSET_DBINIT);
dbinit.AddProperty(DBPROP_AUTH_PASSWORD, "yhwha");
dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
dbinit.AddProperty(DBPROP_AUTH_USERID, "sa");
dbinit.AddProperty(DBPROP_INIT_CATALOG, "gesmed");
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "sem1");
dbinit.AddProperty(DBPROP_INIT_LCID, (long)1036);
dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
hr = db.OpenWithServiceComponents("SQLOLEDB.1", &dbinit);
if (FAILED(hr))
return hr;
hr = session.Open(db);
if (FAILED(hr))
return hr;
CDBPropSet propset(DBPROPSET_ROWSET);
propset.AddProperty(DBPROP_CANFETCHBACKWARDS, true);
propset.AddProperty(DBPROP_IRowsetScroll, true);
propset.AddProperty(DBPROP_IRowsetChange, true);
propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_INSERT | DBPROPVAL_UP_DELETE );
hr = CCommand<caccessor<carticle> >::Open(session, "SELECT * FROM dbo.ARTICLE", &propset);
if (FAILED(hr))
return hr;
return MoveNext();
}
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_ARTICLETESTSET_H__F9F350D0_CB82_11D9_B5A3_0001022AAD75__INCLUDED_)
I learn my self
|
|
|
|
|
mikobi wrote:
hr = session.Open(db);
if (FAILED(hr))
return hr;
Shouldn't you be looking at CDaoException or CDBException to see why the Open() call failed?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hey,
can you tell me why SetButtonInfo has no effect in a CFormView. I first created a Dialog (CDialog)with a embedded Toolbar. In this case I used SetButtonInfo to enable/disable ToolbarButtons. Now I created a Dialog derived from CFormView. When I now use SetButtonInfo the button "flickers" shotly but nothing else....
Do I have to create a
ON_UPDATE_COMMAND_UI function and a status-variable for each ToolBarButton in my CFormView class, or is there an easier way?
Thank you all....
|
|
|
|
|
AnTri wrote:
Do I have to create a
ON_UPDATE_COMMAND_UI function and a status-variable for each ToolBarButton in my CFormView class, or is there an easier way?
Yes and No. You're better off to use ON_UPDATE_COMMAND_UI, and compared to that method, all other possible solutions are painfully difficult.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hello.
please, help me with this problem.
the program is to parse HTTP messages. From the RFC 2616 (HTTP/1.1):
"The HEAD method is identical to GET except that the server MUST NOT
return a message-body in the response. The metainformation contained
in the HTTP headers in response to a HEAD request SHOULD be identical
to the information sent in response to a GET request."
It means the response will inlude the Content-Length header but will have no body.
How to differ response on HEAD method and on GET?
While the connection is persistent the client can send a lot of HEAD requests one by one or in another order. The headers of these (GET and HEAD) responses are identical,but in case of HEAD the parser must not parse message-body.
How to differ them?
Thank you.
|
|
|
|
|
How does one convert from CComBSTR to std::string? With std::wstring it is LPCWSTR(CComBSTR), but for std::string I get a lot of error messages
I am the handsome one in the crowd.
|
|
|
|
|
I suspect that these 'errors' have a lot to do with the differences in the character types (ANSI and Wide character types).
See this[^] MSDN article. This may help you find your solution.
I Dream of Absolute Zero
|
|
|
|
|
Is it possible in an MFC/MDI application to prevent the last window from being closed e.g. if someone accidentally clicks the 'X' on the lat window?
TIA
|
|
|
|
|
yes you can.
just overloads the WM_CLOSE event (OnClose() event handler)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thanks for the reply.
Is it the child frame OnClose() that I should overload?
TIA
|
|
|
|
|
it is the OnClose of the Dialog you want to prevent from closing... (the child if it is the child...)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Just overload the OnCancel() event hadler as toxcct told you
and write the following inside
void CYourDlg::OnBnClickedCancel()
{
if (MessageBox("Are you sure to exit ?","msgboxtitle",MB_YESNO|MB_ICONQUESTION) ==IDYES ) OnCancel();
}
m0n0
|
|
|
|
|
When I rotate my bitmap to a degree which is not a multiple of 90 the size of the image increases to accommodate the new rotated bitmap. E.g. 45 degrees
My problem arises, when I rotate an image of resolution 768*576 the new size increases drastically. Will it be logical to rotate and then resize the bitmap back to the original size for every rotation?
I have also tried using XForm, it works great but it does not allow me to save the rotation. Is there an alternative. If not, where do I find an algorithm to resize a
24- Bit Bitmap.
|
|
|
|
|