|
iayd wrote: How can I close a messagebox without using the Mouse?
Spacebar, Alt+F4, Alt+Space then either X or C.
iayd wrote: For example I want that the messageBox will close by itself after 10 seconds.Can I do that?
Yes. See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
On the time you can send WM_CLOSE to it.
|
|
|
|
|
This is a code I use in my app:
<br />
IStream* data = NULL;<br />
HRESULT hr = S_OK;<br />
hr = SHCreateStreamOnFileW(name,STGM_READ | STGM_SHARE_DENY_WRITE,&data);<br />
When I compile i get error saying:
error LNK2001: unresolved external symbol __imp__SHCreateStreamOnFileW@12
fatal error LNK1120: 1 unresolved externals
What to do?! Thanks
|
|
|
|
|
|
I added:
#include shlwapi.h
in my code,also added:
ShLwApi.Lib
in project settings link input category and put lib path 'D:\VistaSDK\Lib' in additional library path (also in setings).
Now when build error:
uuid.lib(oaidl_i.obj) : fatal error LNK1103: debugging information corrupt; recompile module
???
THX
-- modified at 6:26 Friday 20th July, 2007
|
|
|
|
|
|
Hi, everyone!
I've a problem about UDP. I don't know whether this should be submitted here. If shouldn't, plz tell me the apporiate position.
I'm developing an application which can communicate with other machine through Network using UDP. I create a new thread to listen the income. This thread function is a member of the class manageing the socket. I find a strange phenomenon that I must destroy the thread and create a new one after I send message. Or I can't receive anything from the target I had just sent to. I think the actual fact shouldn't be as this. But I don't know the reason. So I hope someone can help me to resolve this problem. Thx!
The fraction of the thread function:
UINT CMySocket::ReceiveThread(LPVOID lpParam)
{
CMySocket *parent=reinterpret_cast(lpParam);
BYTE buf[1024];
DWORD dwLength;
int ret,addrlen,err;
CWinThread* AcptThread;
fd_set fdread;
SOCKET ListenSock,ClientSock;
ClientSock=parent->sClient;
struct timeval timeout;
dwLength=1024;
if(parent->m_ConWay==0)
listen(parent->s,SOMAXCONN);
addrlen=sizeof(parent->inaddr);
while(bRun)
{
ListenSock=parent->s;
FD_ZERO(&fdread);
FD_SET(ListenSock,&fdread);
timeout.tv_sec=0;
timeout.tv_usec=100;
if((ret=select(0,&fdread,NULL,NULL,&timeout))!=SOCKET_ERROR)
{
if(ret>0)
{
switch(parent->m_ConWay)
{
case 0:
ClientSock=accept(parent->s,(struct sockaddr*)&parent->inaddr,&addrlen);
if(ClientSock!=SOCKET_ERROR)
{
parent->sClient=ClientSock;
AcptThread=AfxBeginThread(AcceptThread,parent,THREAD_PRIORITY_NORMAL,0,
CREATE_SUSPENDED,NULL);
if(AcptThread==NULL)
{
return GetLastError();
}
else
{
bRun=TRUE;
AcptThread->ResumeThread();
return 0;
}
}
else
err=GetLastError();
break;
case 1:
ret=recv(ListenSock,(char*)buf,1024,0);
err=GetLastError();
if(ret>0)
parent->Recive((char*)buf,ret,err);
break;
case 2:
ret=recvfrom(ListenSock,(char*)buf,dwLength,0,
(struct sockaddr*)&(parent->inaddr),&addrlen);
err=GetLastError();
if(ret!=SOCKET_ERROR&&ret!=0)
{
char addr[17];
memset(addr,0,17);
memcpy(addr,parent->inaddr.sa_data,14);
//parent->Recive((char*)buf,ret,err);
parent->inform_recv(parent->m_pOwner,buf,ret,addr);
}
break;
}
}
}
}
return 1;
}
regard!
whiteclouds
|
|
|
|
|
I started reading your code and stopped when I saw the listen() call.
Why are you using listen() if you're trying to use UDP?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Remember the five Ds of dogeball: Dodge, Dip, Duck, Dive, and Dodge."
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
The code I paste upper is a general function which can also be used in TCP connection. The listen() can't be called in UDP. I used a varriable m_ConWay to distinguish them. As I use UDP, m_ConWay=2.
Someone tell me the reason of this problem may be the peer close the socket. But I couldn't find the socket be closed. So I wish you can help me to analyze it. Thx!
Regard!
whiteclouds.
|
|
|
|
|
whiteclouds wrote: The listen() can't be called in UDP. I used a varriable m_ConWay to distinguish them. As I use UDP, m_ConWay=2.
OK thanks
This is something you really need to debug. With UDP you have no way of knowing if the other
end receives what you send or if the other end's socket closed. There's also no guarantee a
datagram will even get to the other end.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have Hindi Text and want to display it on a Dialog Box, but the problem comes when i m reading it from a file.
It shows weird characters like "ऊ ठठठ分有点晕,"
I am using fread function to read these Hindi Text.
and converting it to wide characters using
mbstowcs(buf0,str0,l_Len0+1);
SetDlgItemTextW(m_hWnd,IDC_MY_TEXT,buf0);
where buf0 is wchar_t and str0 is the above weird characters.
Can anyone tell where I am going wrong ???
|
|
|
|
|
Suneet.03 wrote: SetDlgItemTextW
Why are you using the specialized version of the function ? You should use SetDlgItemText instead, this will 'link' to SetDlgItemTextW if UNICODE is defined. If you get a compilation error, it probably means that you didn't define UNICODE and I don't think you'll be able to display a unicode string in that case.
|
|
|
|
|
If the characters in the file are Hindi then they're probably already wide characters so you don't want to be converting them. Read wide characters from the file in the first place and just display them. (I'm guessing you're already using a Hindi capable Font like Arial UNICODE)
If they're not wide characters but from a Hindi Code Page then things are more complex and you need to make sure your program is set to use that code page before doing the mbstowcs conversion. This will also depend on whether you're using Hindi Windows or US/English Windows with the input language set to Hindi. Welcome to the frustrating world of internationalisation (i18n for short)
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
yaa, I am using US/English Windows with Input language set to Hindi
How can I make my program to use the Hindi Code page.
and I am struck at reading them from file, why is it showing those characters
|
|
|
|
|
If you're using US/English Windows then you'll want to use UNICODE for your program rather than setting up for a specific code page. Have a look at MultiByteToWideChar[^] you'll need to find out which code page was used to create the text file and put that actual value into the first parameter instead of one the standard ones. I gather Hindi is normally 1137. Make sure your code is fully UNICODE compliant ( _T("") macros for the text and TCHAR or WCHAR or wchar_t everywhere and wcslen or tcslen type CLibrary calls instead of strlen , UNICODE and _UNICODE predefined as symbols for the project. )
Remember that whenever you see the characters, even in the debugger, you're seeing them translated in one way or another so don't worry if the Hindi doesn't show properly everywhere as long as it works when your code puts it on the screen.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanx for such quick replies.
If that is the case then I fear , I have 2 make lot of changes.. sine I have used _MBCS during compilation
and using strcpy and strlen everywhere....
Can you tell me instead of strcpy what function can i use..
same way as strlen is for _tcslen
|
|
|
|
|
Programming for UNICODE is a big topic and you may want to do some research before embarking on a rewrite if your project. However here's a starter
strcpy only handles 8 bit char(s) as you know
wcscpy only handles 16 bit WCHAR(s)
_mbscpy handles multibyte characters (unsigned long apparently)
see here[^]
_tcscpy is really a macro which turns into wcscpy if your build your project for UNICODE, _mbscpy if you build with _MBCS defined and strcpy if you build your project without UNICODE or _MBCS defined.
Similarly TCHAR becomes WCHAR or char or presumably unsigned long.
Personally I would stay clear of all the _MBCS stuff and stick with 2 builds, One with UNICODE defined and one without for the same source. Try to use the _t functions, like _tcslen, everywhere and remember to wrap your string constants with the _T macro e.g. _T("Some Text"). Most if not all your code should work in both builds. Any features that only work in UNICODE, like dealing with Hindi, might get excluded from the non UNICODE build with #ifdef UNICODE.
Unfortunately things are not quite that simple. Microsoft now recommend we all use Safe String functions, see here[^] and all the various _s extended variants of the normal C Library functions with extra parameters to enable buffer overrun protection.
I hope this is enough to give you a start. If it looks like a mess I'm afraid it is and the only way through is really to pick a standard way of doing things and stick to it rigerously. Of course it helps if you pick the right way for your application and that can be hard.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
After making the changes still , getting the weird characters while reading from file ( file has hindi characters)
Can anyone tell how can i read a Text file having hindi charcters.
Do I need to set some Font in my VC++ program so that i can display this Hindi Text on to the dialog.
Confused !!!!!!!
|
|
|
|
|
Sorry to hear you're still struggling. You will need the font used on the dialog to contain Hindi, e.g. Arial UNICODE MS. To determine if this is really the problem you need to check the values of the wide characters you're actually writing out. Then look them up against the font you're using in the Windows Character Map tool. Accessories/System Tools/Character Map on the Windows Start Menu. This will let you see what's in the font for that code point. If the font is not the issue and the code points are wrong then you need to take one step back and look again at how you get those character values. you could even try examining the original file in a hex editor to see if it contains valid character values that correspond to the characters you're expecting to see. It is possible that the byte-order of the 16bit words has been reversed, depending on where the file comes from and this could cause the characters to appear as rubbish. For example U+0936 (Hexidecial) is श but U+3609 (Hexidecimal) is missing even fom Arial UNICODE MS and would probably result in a blank or a square box.
You could always post some of the original file if you can't make any sense of it.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
hi
in my program if i click on a file name the file should be opened in my mdi application..using
pDocTemplate->OpenDocumentFile i'm opening the file..its working fine.. but if i again click the same file name its getting opened again although the file is already opened..
so i thought to use MatchDocType function but i don't know
correct way to implement it...the argument
MatchDocType (filename,CDocument (*& rpDocument))..here in this place i don't know what i've to giv for
CDocument (*& rpDocument)...any suggestions please so that the file already opened should not get opened again...
thanx in advance..
|
|
|
|
|
If I call PostMessage() inside MidiInProc() function, there is an error saying:
error C2352: 'CWnd::PostMessageA' : illegal call of non-static member function But the documentation for MidiInProc() says "Applications should not call any system-defined functions except for some functions like PostMessage() ".
Any help would be greatly appreciable!!
Best Regards,
Suman
|
|
|
|
|
this error C2352 occurs if
A static member function called a nonstatic member function. Or, a nonstatic member function was called from outside the class as a static function.
The following sample generates C2352:<br />
class CMyClass<br />
{<br />
public:<br />
static void func1();<br />
void func2();<br />
static void func3()<br />
{<br />
func1();
func2();
}<br />
};<br />
<br />
int main()<br />
{<br />
}<br />
The following sample generates C2352:<br />
class MyClass<br />
{<br />
public:<br />
void MyFunc()<br />
{<br />
}<br />
<br />
static void MyFunc2()<br />
{<br />
}<br />
<br />
};<br />
<br />
int main()<br />
{<br />
MyClass::MyFunc();
}<br />
I hope you inderstand what you need to change...I must confess I gave you details from MSDN Library only
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
I want to call a function directly or by posting a user defined message when particular message MM_MIM_LONGDATA comes in MidiInProc() .
I will check your suggestion.
Thanks for your help!!
Best Regards,
Suman
|
|
|
|
|
Hi
Documentation says PostMessage() API;
not the CWnd member function;
|
|
|
|
|
If you check the help for "MidiInProc" in Help Menu --> Index of VC .Net 2003 IDE, you can see the same documentation I saw under "Remarks".
Thanks for the help!!
Best Regards,
Suman
|
|
|
|