|
Why do you want to do this?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I want to build a firewall.
check the one I've done until now. It is on codeproject
gabby
|
|
|
|
|
Is the folder on an NTFS volume?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
yes it is on NTSF volume.
But if you can help me on FAT as well please tell me. I want to build a firewall.
Please if you want you can check the one I've poetd as article
I want a better one
gabby
|
|
|
|
|
Check out MSDN articles Q279682 and Q285998 for examples. They are VB, but easy enough to port over to C++.
Here are a few C++ examples, too:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ad/ad/example_code_for_checking_for_a_control_access_right_in_an_ace.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ad/ad/example_code_for_setting_an_ace_on_a_directory_object.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ad/ad/example_code_for_setting_a_control_access_right_ace.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msmq/msmq_using_queue_security_850z.asp
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
I'm working on a MFC application with a CScrollView derived view class. Everything is working fine, except that when I use double buffering, the text comes out "blurry". I can't quite explain how it looks, but without double buffering, the text comes out as expected, but using double buffering, it kind of seems like everything is drawn twice, a pixel apart.... (I know it's not much of an explanation, but it's the best I got )
Any ideas's on why this is happening? It's not happening with any other drawing that I'm doing...
Another thing I need some help on is the print preview:
The regular print seems to be working fine, but in the print preview, everything is scaled down, and is displayed basically without margins. This probably has a easy solution, but anyways....
Thanks!
Edit: Forgot that some migth enjoy a bit of source code to go along with my first problem:
<br />
void CITPAXpertView::OnDraw(CDC* pDC)<br />
{<br />
CITPAXpertDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
if (!pDoc)<br />
return;<br />
<br />
int nWidth = GetDocument()->GetDocSize().cx;<br />
int nHeight = GetDocument()->GetDocSize().cy;<br />
Graphics graphics(pDC->m_hDC);<br />
<br />
#ifdef _DEBUG<br />
#undef new<br />
Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
#define new DEBUG_NEW<br />
#else<br />
Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
#endif<br />
<br />
Graphics* graph = Graphics::FromImage(bmp);<br />
<br />
CRect area;<br />
area.SetRect( 0, 0, 100, 100); TextPrint(&graphics, 10, 0, area, "Hello!", 1);
area.SetRect( 100, 0, 200, 100); TextPrint(graph, 10, 0, area, "Hello!", 1);
<br />
graphics.DrawImage( bmp, 0, 0, nWidth, nHeight);<br />
delete graph;<br />
delete bmp;<br />
}<br />
The TextPrint is as follows:
<br />
void CITPAXpertView::TextPrint(Graphics* pdc, int height, REAL rotation, CRect area, CString text, int alignment, Color fargen)<br />
{<br />
FontFamily fontFamily(L"Arial");<br />
Font font(&fontFamily, (REAL)height, FontStyleRegular, UnitPixel);<br />
RectF areal( (REAL)area.left, (REAL)area.top, (REAL)(area.right - area.left), (REAL)(area.bottom - area.top));<br />
StringFormat stringFormat;<br />
<br />
SolidBrush solidBrush(fargen);<br />
<br />
if (alignment == 0) { stringFormat.SetAlignment(StringAlignmentNear); }<br />
else if (alignment == 1) { stringFormat.SetAlignment(StringAlignmentCenter); }<br />
else { stringFormat.SetAlignment(StringAlignmentFar); }<br />
<br />
stringFormat.SetLineAlignment(StringAlignmentCenter);<br />
<br />
WCHAR* tekst = new WCHAR[text.GetLength()+1];<br />
mbstowcs(tekst, text, text.GetLength()+1);<br />
<br />
if( rotation != 0 ) {<br />
pdc->TranslateTransform(-areal.X-areal.Width/2, -areal.Y-areal.Height/2, MatrixOrderPrepend);<br />
pdc->RotateTransform(-rotation, MatrixOrderAppend);<br />
pdc->TranslateTransform(areal.X+areal.Width/2, areal.Y+areal.Height/2, MatrixOrderAppend);<br />
pdc->DrawString(tekst, -1, &font, areal, &stringFormat, &solidBrush);<br />
pdc->ResetTransform();<br />
}<br />
else {<br />
pdc->DrawString(tekst, -1, &font, areal, &stringFormat, &solidBrush);<br />
}<br />
<br />
delete tekst;<br />
}<br />
I hope this helps, and maybe, just maybe, someone can help me out...
|
|
|
|
|
Hi there,
I am interested in catching all exceptions that could happen in my piece of MFC VC++ code. Up until now i have used been using Catch(CException *pException), but i noticed it doesn't catch divide by zero. To work around this someone recommended that I use Catch(...), is this best way for catching all exceptions. BTW what role does '...' play within C++? Never come across it before.
Thanks In Advance
Rich
|
|
|
|
|
|
Hi,
I am trying to store a message dialog resource in a DLL so that I can use it in all my applications.
I have had a bit of success thanks to Johan Rosengren, so now I can store the dialog resource in the DLL and use it in my application.
The problem I am still having is when I try and call functions that are part of the MFC framework. Like GetAfxAppName() or any of the Registry Profile functions.
Is there any way I can get this methods to work inside the DLL? or is it just a lost cause
Thanks
Mark
|
|
|
|
|
...
MHillary wrote:
thanks to Johan Rosengren
...and here I am again
Did you check AFX_MANAGE_STATE ? You should do a search on MSDN (www.msdn.microsoft.com[^]) and read up on the subject, it's a bit long to quote verbatim.
|
|
|
|
|
Hi,
I did, basicly what I've done is create a header file called Dialogs with simple C methods in it with names like ShowMessageDialog(...) ShowProgressDialog(...) etc In each one I've got AFX_MANAGE_STATE(GetStaticModuleState( )); Before I make any calles into MFC.
The problem that I found though is that switches everything over to the DLL, so when I call AfxGetApp() an assert is generated.
In the case of the Application Name I've called GetAfxAppName() before AFX_MANAGE_STATE and then passed that string to the dialogs constructor. But for things like the registy functions it just doesn't work.
Cheers
Mark
|
|
|
|
|
Hm, I tested this:
__declspec( dllexport ) void Test()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CWinApp* p = AfxGetApp();
}
and I got the correct pointer to the app. You might also perhaps try passing in a pointer to the app (although it should be unecessary), try using a wrapper class for the registry - there is a ton of articles with registry-classes here
|
|
|
|
|
Hi,
I tried doing that test as well. I created two projects. One was a MFC application and one was MFC dll.
I placed the test function in the dll and called it from the app. I got NULL returned by AfxGetApp(). So if I call something like AfxGetAppName() I get a runtime error.
What type of dll do you create?
Cheers Mark
|
|
|
|
|
A Regular DLL with MFC dynamically linked
|
|
|
|
|
How can I trap when my dialog or window has become inactive like when the user has clicked on another window?
I have tried WM_KILLFOCUS but that does not work.
Also how can I test if a click is on the title bar of my window?
|
|
|
|
|
Anonymous wrote:
How can I trap when my dialog or window has become inactive
Handle WM_ACTIVATE .
Anonymous wrote:
how can I test if a click is on the title bar of my window
Handle WM_NCLBUTTONDOWN and send the (x,y) coordinates in a SendMessage (WM_NCHITTEST, ...) call and compare the return value with HTCAPTION .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi,
Have got few doubts about dll loading and unloading.
I have an application with some 8 to 10 dlls (some using statically linked MFC and some ATL dlls). When I launch the application, I see that the dlls are loaded more than once. I think the OS is loading and unloading these dlls atleast 2 or 3 times and then it gets loaded finally.
* How can I stop this behaviour and load my dlls only once when the application is launched and it is unloaded only when I quit the application?
* Should I release all the memory I allocate in a dll when the dll is unloaded?
TIA
satya
|
|
|
|
|
Hi,
How can I iconize my application through program?
TIA
satya
|
|
|
|
|
AfxGetMainWnd()->PostMessage (WM_SYSCOMMAND, SC_MINIMIZE);
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I wonder how i can enable the frontpage extension for a website on IIS by coding. (i don't care what kind of language the code is written in)
I can't find any help from google about this.
I appreciate if you can help.
Thanks.
|
|
|
|
|
I want to ask something about WinSock. I use it to make connection-Oriented program, I make "PREPARING" for the client and server socket: socket(); setsockopt(SO_RCVTIMEO); set IP address and port for the socket; and finally bind();
For the client, connect(); send(); and there is no SOCKET_ERROR.
Then, for the server, I make listen(); and then the following code:
while(TRUE)
{
iRet=0;
iRet = select(2,&serverReadFD,NULL,NULL,&selectTimeout);
if(iRet == SOCKET_ERROR)
{
AfxMessageBox("ERROR SOCKET SELECT");
closesocket(serverSocket);
return 0;
}
else if(iRet >0)
{
if(FD_ISSET(serverSocket,&serverReadFD))
{
int addrLength=sizeof(sockaddr);
clientConnection = accept(serverSocket,
(struct sockaddr*)&connectionInfo,&addrLength);
if(clientConnection == INVALID_SOCKET)
{
AfxMessageBox("ERROR SOCKET ACCEPT");
closesocket(clientConnection);
closesocket(serverSocket);
return 0;
}
FD_SET(clientConnection,&mainReadFD);
}
else
{
//
iRet = recv(clientConnection,msgData,sizeof(msgData),0);
if(iRet == SOCKET_ERROR)
{
AfxMessageBox("ERROR SOCKET RECEIVE");
closesocket(clientConnection);
closesocket(serverSocket);
return 0;
}
else if(iRet >0)
{
//AfxMessageBox("IN SOCKET RECEIVE");
CString tmp;
tmp.Format("%d",_T(msgData));
::PostMessage(data->mainHandler,WM_DATA_MSG,
(WPARAM)AllocBuffer(tmp),0);
tmp.Insert(0,"REPLAY: ");
iRet = send(clientConnection,(const char*)tmp.GetString(),
tmp.GetLength(),0);
if(iRet == SOCKET_ERROR)
{
AfxMessageBox("ERROR SOCKET SEND");
closesocket(clientConnection);
closesocket(serverSocket);
return 0;
}
memset(msgData,'\0',sizeof(msgData));
}//END RECV CONNECTION
}
}// END SELECT SUCCESS
FD_ZERO(&serverReadFD);
serverReadFD=mainReadFD;
}//while(TRUE)
There is no SOCKET_ERROR either, but the server infinitly receive the Client message "There is no problem in the accept() function".
By debug, I saw that select() return every time the socket that make the connection with the client is ready to receive data.
about the send() functin code in the client thread, here is the code:
while(TRUE)
{
::PeekMessage(&threadMsg,NULL, WM_USER, WM_APP, PM_REMOVE);
if(threadMsg.message == WM_SEND_MSG)
{
iRet = send(clientSocket, (const char*)threadMsg.wParam,
sizeof(threadMsg.wParam), 0);
if( iRet == SOCKET_ERROR )
{
AfxMessageBox("ERROR SOCKET SEND FROM CLIENT");
errorMsgHandler(data->mainHandler, WSAGetLastError());
closesocket(clientSocket);
return 0;
}
}
}//END WHILE (TRUE)
HELP ME PLEASE . . . .
ABO OSAMA
|
|
|
|
|
I downloaded the original Quake II game source code from:
ftp://ftp.idsoftware.com/idstuff/source/quake2.zip
which was released open-source by id software under the GNU public
license:
http://www.fsf.org/copyleft/gpl.html
The game was rewritten in C language. I'm trying to re-compile
it in VS.Net 2003 from ground-up.
When I open the VS.Net 2003, I chose "new project", then in Visual C++
project, I chose "Win 32 project", then selected "window application"
and "empty project".
However, I don't know what's next. I have tried to open the soluation
file in the original quake 2 source, and see what's inside. I was there
are six projects under the soluation. ctf, game, quake2, ref_gl, ref_soft.
The reason I want to try to re-compile it again from "ground-up" is because I
want to know how a big project is managed in VS.Net. Please, would anyone
please help me?
Thanks.
|
|
|
|
|
|
Thanks for your reply. I have both original version and
.Net version. When I say I want to re-compile it again
from ground, I mean not opening the soluation file, but
to build a new project, then copy the files to my newly-
created project.
Anyone?
|
|
|
|
|
Is there anyone that have source code to make interface like norton commander/total commander ?
Norton commander has two panels,drag & drop for both panels, and syncronization between them.
|
|
|
|
|