|
In the dialog's constructor, you'll need to call LoadAccelerators() . Then you'll need to override the PreTranslateMessage() method like:
BOOL CMyDlg::PreTranslateMessage( LPMSG pMsg )
{
if (NULL != m_hAccelTable)
{
if (::TranslateAccelerator(m_hWnd, m_hAccelTable, pMsg))
return(TRUE);
}
return CDialog::PreTranslateMessage(pMsg);
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thats it! Now it works even in a Dialog. Thanks!
|
|
|
|
|
Hi I am controlling an electrical circuit using the computer through the computer ports. I am trying to capture a fast changing analog signal using sampling. So I am just enquiring about the maximum frequency that we could set the timer to using the following function:
SetTimer(1, 2000, 0);
I actually want the timer to interrupt every ten micro seconds (10uS). Is it possible with this type of timers. If not, can anyone guide me to a timer that is capable of doing so.
Thanx in advance
|
|
|
|
|
Timers are set in milliseconds and therefore do not have the resolution you require.
I suggest that you use another thread to do this work. You could then use the high-resolution performance counters QueryPerformanceCounter() and QueryPerformanceFrequency() to monitor the time.
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)
|
|
|
|
|
Are these actually counters or are they functions that retrieve the frequeny and index of a counter?
Check out this link plz.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timerfunctions/queryperformancefrequency.asp
|
|
|
|
|
I was suggesting that you uses the performance counter functions in order to write your own high-resolution timer.
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)
|
|
|
|
|
Ahhaaa.. Ok then, but these are useful functions as well, Thanx Ant.;)
|
|
|
|
|
I created a simple user control in C# which has a button in it.
//DemoControl.cs
namespace DemoControl
{
public class UserControl1 : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Button button1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public UserControl1()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 16);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(88, 32);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// UserControl1
//
this.Controls.Add(this.button1);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(608, 248);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.UserControl1_MouseMove);
this.ResumeLayout(false);
}
#endregion
}
}
The i created an MFC ActiveX control to host the C# control
//HostCtrol.cpp
int CMfcHostCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
AfxEnableControlContainer();
DemoControl::UserControl1* pcal = new DemoControl::UserControl1();
CComPtr<iunknown> spunkControl;
spunkControl.Attach((IUnknown*)System::Runtime::InteropServices::Marshal::GetIUnknownForObject(pcal).ToPointer());
CRect rectPlaceHolder;
GetClientRect( &rectPlaceHolder );
m_ctrl.Create(spunkControl, WS_VISIBLE | WS_TABSTOP, rectPlaceHolder, this, 0);
return 0;
}
where m_ctrl is CWinFormsControlWnd class which i downloaded from the MSDN Magazine at http://msdn.microsoft.com/msdnmag/issues/03/03/WindowsForms/default.aspx
It works great, but the hosting application stuck when i press the button.
Does anyone knwos whats wrong?
Amir.
Amir Harel
|
|
|
|
|
I have been trying to make a library to convert VB code to C++. Incase you feel you need something like this please visit http://ezbasic.sf.net/
I will try and post an article about the library on CodeProject if I get enough people who are interested in the project.
Regards,
Vivek Jishtu
|
|
|
|
|
Eeeeeeeeeeeek....
Err, what are the advantages of doing this ?????
|
|
|
|
|
Well quite a few months of effort has gone into the project. And to get something like this as a comment is not the best way of starting things.
|
|
|
|
|
Sorry, that was not my purpose to offense you. There must surely be a lot of work and lot of efforts behind this... But personally I think VB is not enough structured to be a good programming language, so you can make things without understanding what you are really doing... And when mixing it with C++, I think you will loose the benefits of C++ programming (that is have access to almost everything you want).
|
|
|
|
|
Um, I suppose for academic purposes this is quite interesting to do. What do you plan to do with the project?
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)
|
|
|
|
|
Any one ready to buy the idea
It is just an experiment I was trying out to see if something like this could be done. I love programming in BASIC and wanted functions that I used in BASIC in C++.
|
|
|
|
|
hi !
hi,
generally according to msdn, CreateMsgService has two return favlues, S_OK and MAPI_E_NOT_FOUND. Well i used mapi to create a new imail service.I am adding the service to a new profile that i am creating.In some machines it is working perfectly.In some others however there is an error.Note that MAPI is initializing properly and the profile is getting created.However CreateMsg service ( return type hr ) is returning failure , but the failure code is NOT MAPI_E_NOT_FOUND. I have checked that the necessary entries in MAPISVC.inf file is there and the two .dll files , minet32.dll and inetab32.dll is also there.any idea why this error could have occured ?
Actually the original .inf file in that machine didn't jave the entries.So i took the .inf file of a different machine..and put it there.Does that make it a problem ?
Kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason , huh?"
|
|
|
|
|
Dears:
I've upset problem in my ISAPI filter, when i adding this bulk of Code on
OnPreprocHeaders() fucntion , when i open the page the IIS is crashed
with the following error message:
Microsoft Visual C++ Debug Library:
****************************
Debug Error!
Program : C:\Windows\system32\inetsrv\inetinfo.exe
This application has requested the runtime to terminate it in an unusual
way.
Please contact the application's support team for more information
(Press Retry to debug the application)
[Code]
CDatabase dbConnection;
dbConnection.Open("ODBC;DSN=MyDSN;server=mosaicserver;uid=sa;pwd=;database=U
sers");
CRecordset dbRecord(&dbConnection);
//SQL Select Statement
char Sql[1024] = "SELECT ClientID FROM Clients WHERE ClientID = '";
strcat(Sql,"000000000402");
strcat(Sql,"'");
dbRecord.Open(CRecordset::forwardOnly,Sql,CRecordset::none);
//I just dump to file to indicate the process is done well
CStdioFile file("C:\\name.txt",CFile::modeWrite | CFile::modeRead);
file.WriteString(Sql);
file.WriteString("\n--------------------\n");
SetFilePointer(file.m_hFile,0,0,FILE_END);
file.Close();
I Execute above bulk of as separate MFC Dialogue application and run without
any problems ,,Why the ERROR occured in ISAPI??
Best Regards
|
|
|
|
|
Are you sure that the IIS process has permissions to write to the root of the C: drive? You aren't doing any error checking in the file writing code, and CStdioFile::WriteString will throw an exception (unhandled in your case) if the write operation fails. I'm sure you, running a dialog app as an interactive user, do have permission to write to the drive, which is why it works when you run it that way.
|
|
|
|
|
Dear:
yes, because I did before in same function this bulk of code :
[Code]
//Get the header informaion
BOOL bStatus = pfc->GetServerVariable("ALL_HTTP",Buffer,&BuffSize);
CStdioFile file("C:\\log.txt",CFile::modeWrite | CFile::modeRead);
file.WriteString(Buffer);
file.WriteString("\n--------------------\n");
SetFilePointer(file.m_hFile,0,0,FILE_END);
file.Close();
then i see the Header contents in log.txt without any problems.
but when add the code the relates to Database IIS Crashed!!!!
I dont know why?
The page i have done in .NET (user.aspx) has 3 images 2 buttons and two textboxes ,so for each one the page will do request to IIS ,does that cause the problem? because on each request i open,retrieve information ,and close the database connection.
Thanks
|
|
|
|
|
Dear:
Moreover i tried to debug the ISAPI DLL , the unhandled exception occured at this statement
dbConnection.Open("ODBC;DSN=MyDSN;UID=sa;PWD=;database=Users");
the Message Flaged after excuting above statement
**************************************************
Unhandled exception at 0x7c57e592 in inetinfo.exe: Microsoft C++ exception: CDBException @ 0x00dae950.
Why this happened?
Thanks
|
|
|
|
|
Is MyDSN a user DSN or a system DSN? I suspect that CDatabase::Open is throwing an exception. Should should be catching that, and seeing what the error is.
|
|
|
|
|
Dear :
MyDSN is found in User DSN and File DSN, and after debugging the exception raised is:
Unhandled exception at 0x7c57e592 in inetinfo.exe: Microsoft C++ exception:
CDBException @ 0x00dae950.
this occured after Open() is executed for database connection.
Regards
|
|
|
|
|
Heloo:
I made TRY...CATCH(CDBException,p)...END_CATCH
and dump information to file i got this message
Only SQL_DRIVER_NOPROMPT is allowed when connection pooling is enabled
--------------------
I know where is the problem now.
Regards
|
|
|
|
|
I have been trying to disable Ctrl Tab in my application and its not working
properly. CAn anyone help. Here is what i am doing
<br />
BOOL CMultiApp::PreTranslateMessage(MSG* pMsg)<br />
{<br />
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_CONTROL) <br />
{<br />
OutputDebugString("Control IS PRESSED");<br />
<br />
if(::GetKeyState(VK_TAB) & 0x80000000 )<br />
{<br />
OutputDebugString("Control TAB IS PRESSED");<br />
return FALSE;<br />
}<br />
}<br />
return CWinApp::PreTranslateMessage(pMsg);<br />
}
Omar Alvi
|
|
|
|
|
I am design a program's interface,now I want to make the background of CListCtrl transparent,but I dont know how to implement it,please help me!
hiall
|
|
|
|
|
On Win2K and above you can use SetLayeredWindowAttributes()
This link might help
Making any application transparent in Windows 2000/XP
[^]
NOTE: You can apply this to any window. Including the CListCtrl.
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)
|
|
|
|