|
else
{
printf( "\nKey struck was '%c'\n", _getch() );
}
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I overlooked , that you got answer, reading printf statement in this post. And posted my reply.
Any way, use _getch() , at the start in if statement instead of else . So that it will be executed irrespective of condition.
|
|
|
|
|
Use _getch .
while(1)
{
if(kbhit())
{
_getch();
UINT msg_rc;
msg_rc = MessageBox(NULL,"Are you sure you want to close the TCP/IP Server","Confirmation",MB_YESNOCANCEL);
if (msg_rc == IDYES)
{
exit(1);
break;
}
}
-- modified at 4:18 Friday 16th February, 2007
Didn't noticed that you already got your answer, I ignore your second post, seeing its printf statement.
|
|
|
|
|
Just out of curiosity, why are you using kbhit() and getch() with a GUI application? Those functions had their place with console applications, but with Windows, much more elegant solutions exist.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all,
I have the following piece of code that displays a messagebox, it's working and everything, but how can I display an icon in the message box. I am well aware of the MB_ICONEXCLAMATION, MB_ICONWARNING ... ext, but I want to use a yes - no button with a question mark icon:
msg_rc = MessageBox(NULL,"Are you sure you want to close the TCP/IP Server","Confirmation",MB_YESNOCANCEL);
Many thanx
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
msg_rc = MessageBox(NULL,
"Are you sure you want to close the TCP/IP Server",
"Confirmation",
MB_YESNOCANCEL <code>| MB_ICONQUESTION</code>);
|
|
|
|
|
Thank you very much toxcct ...
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
When using the EDITTEXT control, if I try to use the SHIFT+ENTER (hard line break as defined in MS Word), the resulting text produces a carriage return.
When I look at the string once I have edited and saved the text, the SHIFT+ENTER results in ascii 0x0D (ascii decimal value 13). However, I was expecting it to be ascii 0x0B (ascii decimal value 11).
How could I differentiate an ENTER and a SHIFT+ENTER in a simple text edit control? Or is this not possible in a simple edit text control?
|
|
|
|
|
deivakumar wrote: However, I was expecting it to be ascii 0x0B (ascii decimal value 11).
I'm just curious, why did you expect 0B? That's a Vertical Tab (VT).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Newlines are represented by the sequence \r\n (0D 0A hex) in Windows.
|
|
|
|
|
Hello,
First, I'm pretty sure someone already asked this question, but I couldn't find the right keywords (I did try for about 60 minutes and read pretty much other interesting stuff though), so I hope I'm not annoying anyone.
Anyway, I'm having a multi-document application that each view shows different camera in a 3D scene. I have the code to draw the frame for each view, but of course I need a continuous update. I tried 3 methods and each had its drawbacks so I'd really appriciate any suggestions.
Here are the methods:
1. (The trivial one) - at the end of the code of the OnDraw I'm invalidating the entire view. (this method even that it worked in some other applications I wrote, failed and the application entered deadlock).
2. When view is initialized, I create a thread that paints the view continuously. (deadlock).
3. The thread sends continuously WM_PAINT messages. (works for one view but when I have more than one view the application again enters deadlock)
4. The thread loop send WM_PAINT and then Sleep(1) (works. Sleep(0) enters deadlock.)
5. One thread that sends all the views WM_PAINT (deadlock even with the Sleep).
so now I'm using method 4. The problem in both 3 and 4 is that the framerate drops down. and in 4 it becomes really slow (1/3 of the potential that 3D apps actually can get on the same computer).
does anyone have any idea why does those deadlock happens?
some more information that might be required is that the draw function is implemented in an engine that takes the handle of the window to draw to and it handles itself all the context switching.
maybe I will have to dig in in that engine and see if the problem lies there, but first I wanted to give a shot for the windowing system.
thanks a lot,
Guy.
p.s.
I also appologize for my english.
|
|
|
|
|
Doesn't CDocument::UpdateAllViews fits for your sccenario.
BishGada wrote: does anyone have any idea why does those deadlock happens?
I can tell about 1'st deadlock. You are using Invalidate in OnDraw which will cause endless reccursion.
|
|
|
|
|
Hi
I am trying to create a Windows Service using the function 'CreateService'.
LocalSystem Account service gets created quite easily..
But, when I try to create service with Network Service Account
with 'NT AUTHORITY\NetworkService' or 'NT AUTHORITY\LocalService'
the function fails
Looks I am using the wrong combination of the last 2 params
'lpServiceStartName' and 'lpPassword'...
I am providing...".\user" in 'lpServiceStartName' and pwd in 'lpPassword'
Please guide what are the correct values that have to be passed here...
Thnx
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
AbbyIndian wrote: Looks I am using the wrong combination of the last 2 params
'lpServiceStartName' and 'lpPassword'...
I am providing...".\user" in 'lpServiceStartName' and pwd in 'lpPassword'
NT AUTHORITY\NetworkService is a special built-in user account.
I believe the lpServiceStartName param sould be be "NT AUTHORITY\NetworkService"
and the lpPassword param should be "" (an empty string). Check the docs!
Mark
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
Hi Mark
Yeah..the docs say that and I have used that combination...but its not working.
The function returns Error Code 87..which is 'ERROR_INVALID_PARAMETER'
H E L P !!!
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
Can you post the code for the entire CreateService() call?
Mark
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
Hi..
Here's the relevant code
SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE hService = ::CreateService(
hSCM, m_szServiceName, m_szServiceName,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
szFilePath, NULL, NULL, _T("RCQSS\0"), _T("NT AUTHORITY\NetworkService"), NULL);
..The problem is in the last 2 params only...coz if I make the last 2 params NULL,NULL...the
service gets created and entries are made in the registry with Objectname=LocalService
And I want the ObjectName to be 'NT AUTHORITY\NetworkService'
Another possibility: Maybe, some others params don't just create the perfect combination
when the service name is NetworkService..and hence they also need to be changed when the second last param is 'NT AUTHORITY\NetworkService'...
Thnx
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
Is _T("RCQSS\0") a valid group name? If so, what if you try _T("+RCQSS\0")?
The last two params can affect others. Just for fun, try removing the SERVICE_INTERACTIVE_PROCESS
flag and see if it works.
Also, an empty string (_T("")) should be passed as the last parameter instead of NULL, although
that's most likely unrelated to the problem.
I'm also not sure if you can use SERVICE_ALL_ACCESS access rights under the system network
account.
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
Hi there,
I'm now doing a dialog based application. I have 2 custom control with CWnd base class.
however, one custom control have a vertical and horizontal scroll(lets call it cunstom control 1) and the other (custom control 2) have none. Both is placed side by side. The problem now is , i want to allow the custom control 2(without the scrollbar) to be able to scroll vertically simultaneously when the scrollbar of the custom control 1 is being clicked. Both of the custom control have its own class and how can i do this properly? Any ideas?
Thanks for all constructing ideas.
|
|
|
|
|
overide the WM_HSCROLL and WM_VSROLL message of cunstom control 1. When ever a message of this type arrives, send that message to the cunstom control 2 also.
nave
|
|
|
|
|
Thanks for the reply. Can you give me some examples on how to overide the WM_HSCROLL and WM_VSROLL message? I don't quite understand what you mean. I'm a begineer here, and help is really appreciated for my learning.
Thanks
|
|
|
|
|
|
I've read and also tried to convert and modify it to use for custom control with CWnd application. However the custom control does not scroll synchronously. Can you give me some tips on how to use modify it? I'm a begineer here and i hope that some people here may help me in this.
Thank you
|
|
|
|
|
so i hope when the scroll bar of first custom control is moved, it sends the WM_HSCROLL or WM_VSCROLL message to the 2 nd coustome control also.
So handle the WM_HSCROLL and WM_VSROLL messages in the second window and call ScrollWindow() inside it.
nave
|
|
|
|
|
I am doing a speech SDK related program, below is the code. its designed function is to read the text and save the speech into .wav file. But no voice can be heard when the exe running, I only got the .wav file after the exe finished, what I need is when the program run is running, users can hear the voice, at the same time, the sound is being processed into .wav file.
Thanks for help!
========================================================================
#include <sapi.h>
#include <sphelper.h>
#pragma comment(lib,"ole32.lib")
#pragma comment(lib,"sapi.lib")
int main(int argc, char* argv[])
{
ISpVoice * pVoice = NULL;
if (FAILED(::CoInitialize(NULL)))
return FALSE;
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
{
CComPtr<ispstream> cpWavStream;
CComPtr<ispstreamformat> cpOldStream;
CSpStreamFormat OriginalFmt;
pVoice->GetOutputStream( &cpOldStream );
OriginalFmt.AssignFormat(cpOldStream);
hr = SPBindToFile( L"e:\\output.wav",SPFM_CREATE_ALWAYS,&cpWavStream,&OriginalFmt.FormatId(), \
OriginalFmt.WaveFormatExPtr() );
if( SUCCEEDED( hr ) )
{
pVoice->SetOutput(cpWavStream,TRUE);
WCHAR WTX[] = L"<voice required="\"gender=female\"">Hello world!";
pVoice->Speak(WTX, SPF_IS_XML, NULL);
pVoice->WaitUntilDone( INFINITE );
pVoice->Release();
pVoice = NULL;
}
}
::CoUninitialize();
return TRUE;
}
------------------------------------------------------------------------
Iphone service porviders list
------------------------------------------------------------------------
|
|
|
|