|
|
Hello...
You can destroy this line... I think...
Classicaly, I use this model:
void CCleanUpDlg::OnTimer(UINT nIDEvent)
{
switch(nIDEvent) {
case 1:
...
break;
case 2:
...
break;
...
}
}
nIDEvent is the number of the timer which is activated...
Hello World!!!
from Raphaël
|
|
|
|
|
You don't really need to call base class for your timer if you don't want to:
void CCleanUpDlg::OnTimer(UINT nIDEvent)
{
if (nIDEvent == YOUR_TIMER_ID)
{
}
else
CDialog::OnTimer(nIDEvent);
}
Last Article:
Adding VBScript/JScript to C++ App
Jesus Christ is LOVE! Please tell somebody. P. Selormey and I think the same!
|
|
|
|
|
Hi, I have a Composite Control with a ListControl. I wrote my own CListCtrl derived list control which does automatic column sizing and sorting. Now I want to do some custom drawing but I cannot seem to catch the NM_CUSTOMDRAW message.
I tried catching the message by putting ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw) in the message map, but this does seem to do the trick. I also tried to catch the message in OnNotify but here I can only catch the NM_CUSTOMDRAW from the header.
In the Composite Control class I created a member object of my own list control class (m_list) and in OnInitDialog I attached the list control that I drew in my resource by using m_list.SubclassWindow(GetDlgItem(IDC_LIST1)).
What am I doing wrong here ?
|
|
|
|
|
hi all,
i want to any initialization need to do for CSocket?
in the a demo with SDI structure, i can do all the initial methods (create, connect). but, in my program with dialog structure, i can't do such methods.
i want to know any special stuffs need to do b4?
here is the code, i just direct copy from SDI(demo) to dialog(my code) but failed to work...
CSocket client;
if (!client.Create())
{AfxMessageBox("failed create");}
if (!client.Connect("localhost", 4444))
{AfxMessageBox("failed connect");}
it return "failed create" in my code, but work in the demo.
i want to know whether related to SDI structure?
thanks,
jim
|
|
|
|
|
|
hi,
i did not call this functon. what is it use for?
i can see there is this code in the demo.
thank you! i think it's the problem...
thank you very much!
jim
|
|
|
|
|
Hi,
Have you called AfxInitSockets() ?
-widi
|
|
|
|
|
ok, it's afxsocketinit().
-widi
|
|
|
|
|
Hi,
I need to create an installation process for my project (FTP server). It should be installed as a service. Does anybody have any idea ? Thanks in advance.
Celebrate Mr. Cesilko!
|
|
|
|
|
Following code is from my application for installing services during development. It can help help you to write own one.
void CSInstallDlg::OnInstall()
{
SC_HANDLE schService;
SC_HANDLE schSCManager;
unsigned long int i = SC_MANAGER_ALL_ACCESS;
UpdateData(TRUE);
schSCManager = OpenSCManager(
NULL, // machine (NULL == local)
NULL, // database (NULL == default)
SC_MANAGER_ALL_ACCESS // access required
);
if ( schSCManager )
{
schService = CreateService(
schSCManager, // SCManager database
m_ServiceName, // name of service
m_DisplayName, // name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, // service type
SERVICE_AUTO_START, // start type
SERVICE_ERROR_NORMAL, // error control type
m_PathToExe, // service's binary
NULL, // no load ordering group
NULL, // no tag identifier
TEXT(""), // dependencies
NULL, // LocalSystem account
NULL); // no password
if ( schService )
{
AfxMessageBox(TEXT("Service installed.\n"));
CloseServiceHandle(schService);
}
else
{
AfxMessageBox(TEXT("CreateService failed\n"));
}
CloseServiceHandle(schSCManager);
}
else
AfxMessageBox(TEXT("OpenSCManager failed\n"));
}
void CSInstallDlg::OnRemove()
{
SC_HANDLE schService;
SC_HANDLE schSCManager;
SERVICE_STATUS ssStatus;
UpdateData(TRUE);
schSCManager = OpenSCManager(
NULL, // machine (NULL == local)
NULL, // database (NULL == default)
SC_MANAGER_ALL_ACCESS // access required
);
if ( schSCManager )
{
schService = OpenService(schSCManager, m_ServiceName, SERVICE_ALL_ACCESS);
if (schService)
{
// try to stop the service
if ( ControlService( schService, SERVICE_CONTROL_STOP, &ssStatus ) )
{
while( QueryServiceStatus( schService, &ssStatus ) )
{
if ( ssStatus.dwCurrentState == SERVICE_STOP_PENDING )
{
Sleep( 1000 );
}
else
break;
}
if ( ssStatus.dwCurrentState == SERVICE_STOPPED ) {
} else
AfxMessageBox(TEXT("Service failed to stop.\n"));
}
// now remove the service
if( DeleteService(schService) )
AfxMessageBox(TEXT("Service removed.\n"));
else
AfxMessageBox(TEXT("DeleteService failed\n"));
CloseServiceHandle(schService);
}
else
AfxMessageBox(TEXT("OpenService failed\n"));
CloseServiceHandle(schSCManager);
}
else
AfxMessageBox(TEXT("OpenSCManager failed\n"));
}
|
|
|
|
|
s_k wrote:
I need to create an installation process for my project (FTP server). It should be installed as a service. Does anybody have any idea ? Thanks in advance.
You can use my CServiceHelper class.
http://www.codeproject.com/system/cservicehelper.asp
sample code :-
CServiceHelper m_sh;
m_sh.SetServiceDisplayName("FTP server service");
m_sh.SetServiceName("FTP2000");
m_sh.SetServicePath("D:\\YourSoft\\sftp.exe");
m_sh.SetAutoStart(true);
m_sh.Create();
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Hello,
I need to convert a VC application into a activex. Is it possible to do it. I do have the source code for a particular VC application. I need to convert the VC funtions to activex. So that It will be possible for me to use it in VB.
It is urgent, Please tell any paths to find the solution.
Rajesh Kannan
|
|
|
|
|
do you man you wish to wrap the application as a control to use embedded in the VB application - or do you wish to just automate the application from the VB application
Holy Handgrenade of Antioch instructions
|
|
|
|
|
ActiveX covers a lot of ground. I'll assume you want an activex control.
The easiest way to do this is to create a new project using Visual Studio Appwizard. Select ActiveX Control as the project type.
Once again use the wizard (Classs Viewer) to add the public interface to the control. (What calls the VB program can make to your control.
This results in a skelton of your final control. From here, you just need to move the code from your existing app into the activex control.
|
|
|
|
|
Anyone know how to uninstall deskbands and remove them from the menu in IE?
Somehow while fiddling with the deskband tutorial here on CP I managed to get an empty deskband entry on the deskband menu in IE. I can check and uncheck it and nothing happens (since I used regsvr32 /u to get rid of the dll) but nothing I try makes it drop from the list!
Are these perhaps stored in the registry somewhere? Too bad the menu name is blank or i'd hunt it down!
It seems benign. It just gets on my nerves.
Thanks for any help!
|
|
|
|
|
Hello,
I have 2 questions.. I have researched this for a while and I am very frustrated, so any help will be greatly appreciated. I finally figured out that if your deskband inherits from IPersistStream, explorer won't release the dll when you close the deskband. Why is this??? Second question. Is there a way for a deskband to close itself? In other words, can a deskband tell it's owner that it wants to close?
Thanks
|
|
|
|
|
i have a public DCB variable(DCB m_dcb) in a class called Comm which is in Comm.h file. In Comm.cpp am accessing the m_dcb through a member function. this member function i am calling from the App file. Its compliling & linking. But whrn u go in debug mode or run the appliaction,the member function not able to recognize the DCB variable and throws the error "(MSVCRTD.DLL)0xC0000005:Access violation" at the "FillMemory(&dcb, sizeof(dcb),0);" line.
My code is as follows.
///////////////Comm.h///////////////////////////////////
class Comm
{
private:
BOOL OpenComm(CString strPort);
BOOL SetComTimeOuts();
BOOL SetComState();
public:
Comm(CString port = "COM1");
virtual ~Comm();
BOOL Connect(CString sPort);
BOOL Disconnect();
BOOL ChangeBaudRate(DWORD dwBaudrate);
private:
CString m_strPort;
BYTE* m_pMsgBuf;
public:
static HANDLE m_hComEvent;
static HANDLE m_hCommHandle;
DCB dcb;
OVERLAPPED osReader;
OVERLAPPED osWrite;
BOOL fWaitingOnRead;
BOOL fWaitingOnWrite;
};
//////////////Comm.cpp////////////////////////
#include "stdafx.h"
#include "CEU Simulator.h"
#include "Comm.h"
BOOL Comm::Connect(CString strPort)
{
if(OpenComm(strPort))
if(PurgeComm(m_hCommHandle, PURGE_RXCLEAR | PURGE_TXCLEAR))
return TRUE;
return FALSE;
}
//opencomm
BOOL Comm::OpenComm(CString strPort)
{
m_hCommHandle = ::CreateFile(
strPort,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
NULL
);
if (m_hCommHandle == INVALID_HANDLE_VALUE)
{
return FALSE;
}
/*if(INVALID_HANDLE_VALUE == m_Handle && ERROR_ALREADY_EXISTS != GetLastError())
return FALSE;*/
if( !SetComTimeOuts() )
{
CloseHandle(m_hCommHandle);
m_hCommHandle = INVALID_HANDLE_VALUE;
return FALSE;
}
if( !SetComState() )
{
CloseHandle(m_hCommHandle);
m_hCommHandle = INVALID_HANDLE_VALUE;
return FALSE;
}
return TRUE;
}
// setcommtimeouts
BOOL Comm::SetComTimeOuts()
{
COMMTIMEOUTS commTimeOut;
commTimeOut.ReadIntervalTimeout = MAXDWORD; // | Read operation should return immediately
commTimeOut.ReadTotalTimeoutMultiplier = 0; // |=> with chars that have been revceived, even
commTimeOut.ReadTotalTimeoutConstant = 0; // | even no chars have been received
commTimeOut.WriteTotalTimeoutMultiplier = 2;
commTimeOut.WriteTotalTimeoutConstant = 0;
if( !SetCommTimeouts(m_hCommHandle,&commTimeOut) )
return FALSE; //"error in Commtimeouts"
return TRUE;
}
// setcommstate
BOOL Comm::SetComState()
{
char buf[60];//={'\0'};
// DCB dcb;
FillMemory(&dcb, sizeof(dcb),0);
dcb.DCBlength = sizeof(dcb);
sprintf(buf,"%s:%d,%c,%d,%d","COM1",BAUDRATE,'N',8,1);
if( !BuildCommDCB(buf,&dcb) )
return FALSE; //error in building comm
dcb.BaudRate = BAUDRATE;
dcb.ByteSize = BYTESIZE;
dcb.Parity = FALSE;
dcb.StopBits = FALSE;
dcb.EvtChar = EVTCHAR;
dcb.fDtrControl = TRUE;
dcb.fRtsControl = TRUE;
dcb.fOutxCtsFlow = FALSE;
dcb.fOutxDsrFlow = FALSE;
dcb.fDsrSensitivity = FALSE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
dcb.fTXContinueOnXoff =FALSE;
dcb.XonChar = XONCHAR;
dcb.XoffChar = XOFFCHAR;
dcb.XonLim = FALSE;
dcb.XoffLim = FALSE;
dcb.fBinary = TRUE;
dcb.fErrorChar = FALSE;
dcb.fNull = FALSE;
dcb.fAbortOnError = FALSE;
dcb.fDummy2 = FALSE;
dcb.fParity = TRUE;
dcb.ErrorChar = FALSE ;
dcb.EofChar = FALSE;
dcb.EvtChar = FALSE;
if( !SetCommState(m_hCommHandle,&dcb) )
return FALSE; //error in CommState
return TRUE;
}
//////////////////CEU Simulator.cpp (App file)////////////////////////////////
#include "stdafx.h"
#include "CEU Simulator.h"
#include "MainFrm.h"
#include "CEU SimulatorDoc.h"
#include "CEU SimulatorView.h"
void CCEUSimulatorApp::ConnectToPort(CString strPort)
{
m_comPort.Connect(strPort);
}
//////////////CEU Simulator.h//////////////////////////////////////////////
#include "resource.h" // main symbols
#include "CEU SimulatorDoc.h"
#include "CEU SimulatorView.h"
#include "Comm.h"
class CCEUSimulatorApp : public CWinApp
{
public:
CCEUSimulatorApp();
public:
Comm m_comPort;
void ConnectToPort(CString strPort);
void DisconnectPort();
void SetBaudRate(DWORD dwBaudRate);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCEUSimulatorApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CCEUSimulatorApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
Pls. help
Rsh
|
|
|
|
|
|
You need to define a variable in the first dialig that will hold the value that you want to pass to the second dialog. In the second dialog, define a variable that will receive the value from the first. For example:
class CMyDlg1
{
public:
int m_x; // this is going to be passed to other dialogs
};
class CMyDlg2
{
public:
int m_x; // this is going to be received from CMyDlg1
}
Somewhere in CMyDlg1, you have a button or menu item that when pressed CMyDlg2 is displayed:
CMyDlg1::OnButton1()
{
CMyDlg2 dlg;
dlg.m_x = m_x; // passing a value from CMyDlg1 to CMyDlg2
dlg.DoModal();
}
|
|
|
|
|
Mel:
Thank you very much,Your help is very valuble for me,Ilike to program in VC at my amature time,I like to do something I interesting.
thanks.
|
|
|
|
|
How about doing it the other way around? Ex. using a settings dialog that will change a variable in the main window?
|
|
|
|
|
I'm analyzing the possibility of using RegisterWindowMessage in order to establish communication between two applications.
Is this the best way to accomplish such task? It looks like the easiest one.
rechi
|
|
|
|
|
Registered message or PostMessage(HWND_BROADCAST, ...) are the most simple ways to communicate between GUI applications, if information you need to send can be placed to wParam, lParam.
|
|
|
|
|
I have just created a DLL that has a CreateDisplay funtion that I wanted to be able to pass a time-out value to. When the CreateDisplay function is called, everything is ok BUT the timer functionality. The CreateDisplay function calls a modal dialog that contains 2 text fileds and a hidden button. The dialog created in an MFC App with the same code works fine. (meaning, I know that the settimer and ontimer code is ok). I have thrown in MsgBoxes during the dll's settimer and ontimer code. If the timer message is thrown BEFORE the dialog is drawn, then I get OnTimer hits, however, once it is displayed, I get nothing (spy++ shows nothing as well). And, from the message trick, I know the settime is getting set when I want it to.
So what is my problem???
If it is a message pump thing due to the dll, can someone point me as to what I need to do. (relizing I have never done it)
Thanks.
|
|
|
|