|
In my message map...
BEGIN_MESSAGE_MAP()
...
ON_WM_????
END_MESSAGE_MAP
what is the message used to tell a window to assert the OnRecieve method of a CAsyncSocket object.
|
|
|
|
|
Hello, the codegurus around the world.;)
You need the good book about Socket programming. But, the book about Socket sometimes
use the basic of WinSock, not CSocket or CAsyncSocket class.
I got this code from some Wrox book about MFC, but I forgot this titile.
Define the following the message map entry at CYourAsyncSocket class.
#ifndef WM_SOCKETEVENT
#error You must define 'WM_SOCKETEVENT' as a WM_USER message.
#endif
#ifndef ON_WM_SOCKETEVENT
#define ON_WM_SOCKETEVENT() \
{ WM_SOCKETEVENT, 0, 0, 0, AfxSig_vwwh, \
(AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(UINT, UINT, SOCKET))OnSocketEvent },
#endif
Now, we can use this message function at some Dialog;
// some Dialog header file
afx_msg void OnSocketEvent(UINT nEvent, UINT nErroCode, SOCKET hSocket);
BEGIN_MESSAGE_MAP(CWinFingerDlg, CDialog)
................
ON_WM_SOCKETEVENT ()
END_MESSAGE_MAP()
...................
CMyDialog::OnSockeEvent (UINT nEvnet, UINT nErroCode, SOCKET hSocket)
{
}
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
do you know, how can create MFC application, where buttons will have same style as button "start" (button have icon and caption)
|
|
|
|
|
Yes, try my CButtonST class.
You can find it here: http://www.codeproject.com/buttonctrl/cbuttonst.asp
Let me know if it can help you, bye!
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://members.tripod.com/~SoftechSoftware/index.html
|
|
|
|
|
Thank you,
Can you tell me, how can I draw icon in all controls ?
LB
|
|
|
|
|
If the control supports owner-drawing so this is the way. Else you have to develop a custom control. Bye!
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://members.tripod.com/~SoftechSoftware/index.html
|
|
|
|
|
How do you create a 8 bit/pixel bitmap on the fly useing CBitmap? For example, suppose I just wanted a blue 1000x1000 pixel bitmap but did not want to create it as a resource. (System settings are 32 bits/Pixel) When I try this with CreateBitmap/BitBlt everything seems to succeed but I get only a black output. I can create an appropriate bitmap on the fly if I use the system settings (32bpp) but I would really like a smaller bitmap. I can also create and display a monochrome bitmap with the logic I have, so I know the DC, size and everything is correct. Is the issue that I am inheriting the system palette for the bmp but that I actually need to create my own palette with the appropriate colors? I other words, that the bit values do not refer to the appropriate colors in the palette? I have played around with creating a palette, but to no avail.
|
|
|
|
|
The problem is that you cannot select your bitmap into a DC to draw on it unless your system is running at 8BPP, because a CBitmap is a DDB. You probably want to look into DIBSections, which can be any bit depth and still loaded into any DC and drawn onto. Chris wrote a DIBSection wrapper which is on the site, or you can use paintlib ( which I use ) from www.paintlib.de
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
|
How to update one class's member variable from another class. I have a control bar on the left (CLeftDlg class) and working aarea on the right (CRightDlg). How to update m_strComment (member of CRightDlg) from CLeftDlg.
How to call a non-static member function CRightDlg::Refresh() from CLeftDlg.
Please HELP !!!!!!!
|
|
|
|
|
Your common thread is to call AfxGetMainWnd for SDI/MDI or AfxGetApp otherwise (don't forget to cast it to your specific class ), and then you can get whatever you want from there.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hello, the codegurus around the world.;)
The other way is that we pass the parent's CWnd of the dialog constructor's argument.
This also works for Java.
CWnd *m_pParent;
CMyDialog::CMyDialog (CWnd *pParent)
{
m_pParent = pParent;
}
((CMainFrame*)m_pParent)->m_strComment = something;
CMyDialog (this); :cool:
Or we can use CWnd* GetParent() function to get the parent's CWnd
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
this code cant seem to work properly....
//blah blah code
if (nCount > 0)
{
int nLevel;
for (nLevel=0; nLevel<=3; nLevel++); // after this line, the value of nLevel becomes 4, why????
{
//blah
//blah
|
|
|
|
|
Remove the semi-colon from the end of the for statement.
|
|
|
|
|
I read about some clock synchronizing classes at http://www.codeproject.com/internet/csntp.asp and wanted to give them a try. When building, Visual Studio 6.0 gave an error 'LINK : fatal error LNK1104: cannot open file "mfc42u.lib"'. I then downloaded service pack 5 for Visual Studio 6.0 and tried again. The same error. I've scanned my Studio directory and sub-directories and that file is not on my drive. Has anyone else come across this problem?
Peter
|
|
|
|
|
The Unicode libraries aren't installed in a default installation of VC. Just grab the LIB out of the service pack EXE (there should be a command line switch to unpack it, or just use WinZip) and put it in your MFC\LIB directory.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
|
It is not installed by default. Rerun the Visual Studio install and opt to add/remove components. There's an option to install the unicode libraries and dlls that is available under one of the selections. Install them and try again.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
I want help about thread in visual c++ with a sample
yass
|
|
|
|
|
This code creates a worker thread which executes the code inside the FuncThread Function
#include <iostream> // for cout -> STL
#include <strstream> //for strstream ->STL
#include <string> // for string -> STL
UINT FuncThread(LPVOID lpParam) //this code will be executed within a thread
{
char *msg = (char *) lpParam;
cout << "Received from Caller: " << msg << " Thread Id: (" << GetCurrentThreadId() << ")" << endl;
return 0.;
}
//in some point of your MFC code
string s;
for ( int i = 1; i <= 5; i++)
{
strstream ostr;
ostr << "Message # " << i << endl;
s = ostr.str();
size_t pos = s.find("\n");
s[pos] = '\0';
//this call creates a thread
AfxBeginThread((AFX_THREADPROC) FuncThread, (LPVOID) s.c_str());
}
For more info about threads on VC++ look at MSDN online library.
I hope this helps
Luis
|
|
|
|
|
Hi,
I have a program and somewhere in the program, I need to shutdown the computer. The following code works fine on my machine (W2K) however, it does not work on some other machines ( on Win98 and NT ). It does not shutdown the computer, instead it logs off or reboots the computer.
Please help. Is there any way to shutdown the computer without any problems (not only shutdown but also power off!)?
Best Regards
-----------------------
int CTaskStep::ExecuteShutDown ( CTaskObject *pTask , bool bReboot)
{
HANDLE hProcess = GetCurrentProcess(); // Is pseudohandle, no close needed
HANDLE hToken = NULL;
OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES,&hToken);
if ( hToken )
{
TOKEN_PRIVILEGES priv_struct;
LUID_AND_ATTRIBUTES priv;
LUID priv_luid;
BOOL bRet;
bRet = LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &priv_luid);
priv.Attributes = SE_PRIVILEGE_ENABLED;
priv.Luid = priv_luid;
priv_struct.PrivilegeCount = 1;
priv_struct.Privileges->Attributes = SE_PRIVILEGE_ENABLED;
priv_struct.Privileges->Luid = priv_luid;
bRet = AdjustTokenPrivileges(hToken, FALSE, &priv_struct,NULL,NULL, NULL);
CloseHandle( hToken );
}
// Restart and give message to restart if failed
if ( bReboot )
{
if(!ExitWindowsEx (EWX_REBOOT | EWX_FORCE,0) )
{
CString str;
str.LoadString( IDS_MBOX_FAILED_RESTART );
AfxMessageBox(str,MB_ICONERROR);
m_bFailed = true;
}
}
else
{
if(!ExitWindowsEx(EWX_POWEROFF | EWX_FORCE,0))
{
CString str;
str.LoadString( IDS_MBOX_FAILED_SHUTDOWN );
AfxMessageBox(str,MB_ICONERROR);
m_bFailed = true;
}
}
return EX_CONTINUE;
}
Mustafa Demirhan
|
|
|
|
|
Hi
Does anybody know of an ActiveX, or something else, which I could use to display PDF files in the View of an SDI application I have written?
Thanks in advance
Dave
|
|
|
|
|
No, but you can use IE as a control and pass it a pdf.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Not really true. You can actually do it. However, it is a bit of a hack.
Available methods:
1. Official
Buy the Acrobat program and use the SDK.
2. Hacking!
Acrobat reader actually installs two types of ocx. The real stuff with name
as pdf41.ocx or pdf42.ocx depending on your machine AND a crippling version pdf.ocx
as the so-called main. In some installations the pdf41.ocx/pdf42.ocx in never installed, I have still not taken the time to find the circumstances.
Now, the pdf.ocx will not allow you to use the reader in your view or dialog.
However, pdf41.ocx/pfd42.ocx will.
The trick is to unregister the pdf.ocx and manually register the pdf41.ocx/pdf42.ocx
and you can generate the C++ wrapper classes with the Visual C++ gallery or classwiz.
I did this for a TeX/LaTeX IDE I was working on--an open source effort and we could
not use the paid version!!!
Regards,
Paul.
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan, and open for day job or programming contract anywhere!
|
|
|
|
|
Sorry, I should be careful how I word things - I meant no, I don't know.
Christian
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|