|
maybe a simple C++ project~
can you pls help?? thx very much
|
|
|
|
|
You want something like this?
#include <iostream>
#include <conio.h>
#include <ctime>
using namespace std;
time_t g_Time = 0;
unsigned int g_uInterval;
void SetTimeout(unsigned int uX)
{
g_uInterval = uX;
}
void Begin()
{
g_Time = time(0);
}
bool IsTimeout()
{
if( g_uInterval < difftime(time(0), g_Time) )
return true;
return false;
}
void main()
{
unsigned int uX = 20;
cout << "Press any key in " << uX << " sec.\n";
SetTimeout(20);
Begin();
while(1)
{
if(_kbhit()) {
cout << "Key pressed.\n";
break;
}
if(IsTimeout()) {
cout << "Time out.\n";
return;
}
}
getch();
}
Maxwell Chen
|
|
|
|
|
I need to have a window and a frame inside it.When you push the button,the program must read info from an array,and draw on the frame a black pixel or a white pixel,depending on the value of the current position of the array.That operation will continue until the frame is full with black and white pixels from the whole array.
I don't know how to write the code for that image,and I've been looking lots of info about MFC,but is my first program with MFC.
|
|
|
|
|
I’m geting a runtime-error when calling:
m_myDialog.Create( IDD_RECOURCEDIALOG, this );
in my ActiveX Ctrl OnCreate(..)-method
"m_myDialog" is an Dialoge-recource which I have as a private member of my ActiveX-Ctrl-class
Tanks - Anders
...and justice for all
APe
|
|
|
|
|
How much voltage is required to operate a seven segment LED
keep it up
|
|
|
|
|
Wrong forum, you need to post this in Electronics >Power Requirements >Segment LEDs, this is the Visual C++ forum
|
|
|
|
|
Read the spcification of the LED if you have the NO. Else assume 5 volts.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
I am in the trouble of convert a jpeg file into bmp file ,
it will be appreciated for some one who can help me .
(source code without using the lib etc will be better.)
|
|
|
|
|
|
Thank you but the link has lost!
you sure the address is right?
|
|
|
|
|
Um, That definately was working when I posted the message. Perhaps the site is having problems at present.
I am not sure where the site is hosted but in Manchester UK there was a fire recently that took out many phone lines and sites. They are still reparing the damage.
Give it a while and try again later. It's definately worth a look at.
Ant.
|
|
|
|
|
Thank you for your advice.I'll try later.Maybe something is wrong with the network.I'm in China.
|
|
|
|
|
I wrote a Service prog and create a window in this service to receive remote program's user defined(WM_user+2330) message.but everything is fine except the window cann't receive message.
anyway,my servicetype is SERVICE_INTERACTIVE_PROCESS,why?
thanks a lot!
class CTsapiWnd : public CWnd
{
public:
.......................
void DoCreate()
{ CreateEx(0, AfxRegisterWndClass(CS_GLOBALCLASS), "",0,0,0,0, 0, 0, 0, 0);}
.........................
}
CTsapiWnd * m_TsapiWndPtr;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
ee=1;
m_TsapiWndPtr=NULL;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
SERVICE_TABLE_ENTRY DispatchTable[] =
{
{ ServiceName, ServiceMain},
{ NULL, NULL }
};
StartServiceCtrlDispatcher(DispatchTable);
}
return nRetCode;
}
void WINAPI ServiceMain(DWORD argc, LPTSTR argv[])
{
hSStat = RegisterServiceCtrlHandler( ServiceName, ServerCtrlHandler);
if (hSStat == 0)
LogEvent (_T("Cannot register control handler"), 100, TRUE);
LogEvent (_T("Control handler registered successfully"), 0, FALSE);
HDESK hdeskCurrent;
HDESK hdesk;
HWINSTA hwinstaCurrent;
HWINSTA hwinsta;
hwinstaCurrent = GetProcessWindowStation();
if (hwinstaCurrent == NULL)
{
LogEvent(_T("get window station err"),0,FALSE);
}
hdeskCurrent = GetThreadDesktop(GetCurrentThreadId());
if (hdeskCurrent == NULL){
LogEvent(_T("get window desktop err"),0,FALSE);
}
hwinsta = OpenWindowStation("winsta0", FALSE,
WINSTA_ACCESSCLIPBOARD |
WINSTA_ACCESSGLOBALATOMS |
WINSTA_CREATEDESKTOP |
WINSTA_ENUMDESKTOPS |
WINSTA_ENUMERATE |
WINSTA_EXITWINDOWS |
WINSTA_READATTRIBUTES |
WINSTA_READSCREEN |
WINSTA_WRITEATTRIBUTES);
if (hwinsta == NULL)
{
LogEvent(_T("open window station err"),0,FALSE);
}
if (!SetProcessWindowStation(hwinsta))
{
LogEvent(_T("Set window station err"),0,FALSE);
}
hdesk = OpenDesktop("default", 0, FALSE,
DESKTOP_CREATEMENU |
DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE |
DESKTOP_HOOKCONTROL |
DESKTOP_JOURNALPLAYBACK |
DESKTOP_JOURNALRECORD |
DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP |
DESKTOP_WRITEOBJECTS);
if (hdesk == NULL)
{
LogEvent(_T("Open desktop err"),0,FALSE);
}
if (!SetThreadDesktop(hdesk))
{
LogEvent(_T("Set ThreadDesktop err"),0,FALSE);
}
SetStatus(hSStat, SERVICE_START_PENDING);
m_TsapiWndPtr=new CTsapiWnd;
m_TsapiWndPtr->DoCreate();
Sleep(1000);
..............................................
setStatus(hSStat, SERVICE_RUNNING);
LogEvent(_T("SERVICE_RUNNING"),0,FALSE);
while(ee)
{
Sleep(1000);
}
SetStatus(hSStat, SERVICE_STOPPED);
LogEvent (_T"SERVICE_STOP"), 0, FALSE);
}
|
|
|
|
|
never used (WM_user+xxx) for interprocess communication .
essay on interprocess messages
http://www.codeproject.com/dialog/messagemgmt.asp
also, you are not trying service interaction with desktop in terminal session, right..
greatest thing is to do wot others think you cant suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
I am using TSAPI writing a CTI service prog.
in TSAPI,using function(acsEventNotify) allows an application to request that a message be posted to its application queue when an incoming ACS event available.
when Telephony server's receive queue become non-empty,then it would post a msg(user defined) to application,and after application received this msg ,it will get the msg from receive queue to process.
RetCode_t acsEventNotify
(
ACSHandle_t acsHandle,
HWND hwnd,
UNIT msg,
Boolean notifyAll
);
hwnd: the window which receive notif
msg: user-defined msg to be posted when an incoming event become available.
so in my service,i create a window to receive this msg.but i can't receive any msg.however,when my prog is application,it can run correctly.why
|
|
|
|
|
I search many forums.i think the problem maybe desktop.but servicetype is SERVICE_INTERACTIVE_PROCESS.Then where is err?
apppreciate any help!
|
|
|
|
|
someone can help me how to convert text to wave (don't use sapi of microsoft)???
thanks
Nho'c Ti`
|
|
|
|
|
It's probably affordable to write a web service that sends the text to a call centre in India and takes back an mp3.
Seriously, that's a hell of an ask. If Microsoft provides a speech API, why don't you want to use it ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
|
|
I don't want to use it because i want code in website and client doen't install aspi, but could listen the text voice.
thanks
Nho'c Ti`
|
|
|
|
|
Hi
I am currently building a computationally-heavy application, which requires processing of hundreds of image data, and this processing must also be done hundreds of times. To let users know which image file is currently processed, I simply bound a variable to a static text control, and I update this variable and call UpdateData(FALSE) everytime a new image file is processed.
The application runs fine for the first few iterations. But after it reaches a certain iteration (the exact numbers differ between executions, but they are close to each other), the text control suddenly moves to the topleft of my monitor! Updating of the control is also abnormal (some image files are skipped). Apparently the processing still runs fine, and the result is correct, it's just that the update is messed up.
Could someone shed some light on what may cause this problem and how I can rectify this?
Thanks!
|
|
|
|
|
Try to log some information to a text file...
Maxwell Chen
|
|
|
|
|
I'm guessing that the image processing is done in a different thread than the main application so as to keep the GUI 'snappy'.
If so, there could be an issue with one thread manipulating a window created by another (the main app) thread. This could cause the app to screw up at random. I have seen similar effects related to this before.
I would suggest that the image thread post (not send) a message to the window. The app thread can then update the variable and call UpdateData(FALSE).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Having bint a DataGrid to a data source,I want to modify each colunm's width of DataGrid,what to do next? I tried as below but failure:
CColumns cols=m_DataGrid.GetColumns();
CColumn col;
VARIANT var;
long l=cols.GetCount();
for(long i=0;i
|
|
|
|
|