|
I have to cal this function to enable menu.. OnUpdateFileExit(?)--- what i have to pass in place of CCmdUI argument... confused
void BrowserManager::OnUpdateFileExit(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable ( TRUE );
}
|
|
|
|
|
The OnUpdateXXX handlers should be called auto-magically by the framework when the message ON_UPDATE_COMMAND_UI message is sent.
you need to add a message for that ...
add something like in the message map area of (I don't remember which one) either the application (CWinApp derived class) or the main frame class.:
ON_UPDATE_COMMAND_UI( ID_OF_YOUR_MENU_ITEM, OnUpdateFileExit)
IMO, the Exit menu (quit?) should always be enable.
Watched code never compiles.
|
|
|
|
|
What i want exactly i have a menu item disabled initially.. ? I have a function which check wheteher a Sotware present in System or not and retruns true/false... If it returns true i have to enable the menu item.. If it retuns false do nothing...
Can u explain me how to do this... 
|
|
|
|
|
The ON_UPDATE_COMMAND_UI is called for each menu item when the menu is displayed;
So, when that particular menu Item is displayed, the ON_UPDATE_COMMAND_UI handler is called.
In the function that you specified for the handler (usually called OnUpdateXXX where XXX is a descriptive name of the function based on the menu item) you will check to see if the software is present or not and enable disable the menu item accordingly.
for example (pseudo-coded):
ON_UPDATE_COMMAND_UI( IDM_YOUR_MENU_ITEM, OnUpdateYourMenuItem )
void YourClass::OnUpdateYourMenuItem( CCmdUI* pCmdUI )
{
pCmdUI->Enable( IsSoftwarePresentOnSystem() );
}
If the function IsSoftwarePresentOnSystem() takes a long time, then it would be a good thing to call it somewhere else and have a state variable.
Have fun.
M.
Watched code never compiles.
|
|
|
|
|
yes dude.. I did the same way u explained... but still the menu item remains disabled.. dont know where i went wrong... 
|
|
|
|
|
Can you debug your code ?
-If you put a breakpoint in the OnUpdateXXX method, is it triggered when the menu is displayed (when you open a menu) ?
-Does the function(s) that check you condition (if the software is there or not) works ? did you validate that before ?
M.
Watched code never compiles.
|
|
|
|
|
Hello buddies,
I'm working with openGL to draw line
Im using VC++ 2008 express
<br />
#include <glut.h><br />
#include <math.h><br />
<br />
GLfloat static x = 0.0;<br />
GLfloat static y = 0.0;<br />
<br />
<br />
typedef int BOOL;<br />
#define FALSE 0<br />
#define TRUE 1<br />
<br />
static BOOL button_down = FALSE;<br />
<br />
void draw_line(int x,int y) <br />
{<br />
<br />
glBegin(GL_LINE);<br />
glPointSize(3.5);
glColor3f(1.0,0.0,0.0);
glVertex2f(x,y);
glVertex2f(x,y);
<br />
glFlush();<br />
glEnd();<br />
}<br />
<br />
<br />
<br />
void mouse(int button,int state,int x,int y)<br />
{<br />
if<br />
<br />
( state == GLUT_DOWN) <br />
{<br />
button_down = TRUE;<br />
}<br />
<br />
<br />
if<br />
<br />
<br />
(state == GLUT_UP)<br />
{<br />
button_down = TURE;<br />
} <br />
}<br />
<br />
void init(void)<br />
{<br />
glClearColor(0.0, 1.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION); <br />
glLoadIdentity();<br />
<br />
}<br />
<br />
<br />
void motion(int x,int y)<br />
<br />
{ <br />
if(button_down)<br />
{<br />
<br />
<br />
<br />
}<br />
<br />
<br />
}<br />
void display(void)<br />
{<br />
glClear(GL_COLOR_BUFFER_BIT);
glFlush();<br />
glutSwapBuffers();<br />
}<br />
<br />
<br />
<br />
<br />
int main(int argc, char** argv)<br />
{<br />
glutInit(&argc,argv);<br />
glutInitWindowSize(ww,hh);
glEnable(GL_DEPTH);<br />
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);<br />
glutCreateWindow("draw_line");<br />
init();<br />
glutMotionFunc(motion);<br />
glutMouseFunc(mouse);
<br />
glutDisplayFunc(display);<br />
glutMainLoop();<br />
}
When the mouse press in location it would send the x and y values to draw the start point of the line then i have to release the button to point the end point of the line
So, What I suppose to change the value of x and y in motion function
|
|
|
|
|
Is it possible to change the startup location of a CFileDialog? I am working on a legacy application that makes use of multiple monitors, and I need to be able to position the location of the file load/save dialogs. I derived my own class based on CFileDialog and added what I thought was the appropriate SetWindowsPos call in the OnInitDialog method, but the things just will not move. If I change the windows size instead of the position, it correctly truncates the dialog, so I'm fairly sure I have the right window, yet no matter what values I pass in for the position, the location remains the same. Below is the important code from a test program.
BOOL CMyFileDialog::OnInitDialog()
{
CFileDialog::OnInitDialog();
CWnd *pW = GetParent();
RECT Rect;
pW->GetWindowRect(&Rect);
pW->SetWindowPos( NULL, 10, 10, Rect.right - Rect.left, Rect.bottom - Rect.top, 0);
return TRUE;
}
If it makes any difference this is using VS2005.
|
|
|
|
|
You can..
use CWnd::SetWindowPos[^] with the instance created for CMyFileDialog.
--
"Programming is an art that fights back!"
|
|
|
|
|
Your code is setting the postion of your parent window, not your dialog! In reality it is doing nothing since the origin and size remain the same just moving the parent window to point 10, 10 of the screen.
[edit]Missed the new origin[/edit]
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
The documentation I've seen seems to indicate that you have to actually get the parent of the CFileDialog. Since I can manipulate the size of the dialog this way, it would seem that I have the right window.
Further experimenting with my test program shows that I can in fact move the location of the dialog a limited amount. It appear, however, that something prevents you from moving the dialog so that any of it is off of the screen. Unfortunately, I need to move it to a second monitor which seems to be a problem.
|
|
|
|
|
rentzk wrote: The documentation I've seen seems to indicate that you have to actually get the parent of the CFileDialog.
Here[^] is the documentation for SetWindowPos() . The problem with your code is that you are calling this function on the parent window rather than the dialog, and thus your dialog does not move. If you make the correct call then you should be able to move your dialog anywhere within your monitors.
GetWindowRect(&Rect);
SetWindowPos(pW, 10, 10, Rect.right - Rect.left, Rect.bottom - Rect.top, 0);
I have a feeling that you need to use some special values of x to move it from the main monitor, but cannot recall the exact formula; try searching MSDN or Google.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I don't think it's the documentation for SetWindowPos that is relevant here, but instead the various articles describing how to modify CFileDialog. These articles mention the need to get the parent in order to access the various buttons on the dialog and change it's size. It would appear that this dialog is the child of some other window, but I haven't pulled out win spy yet to see what it is.
When I try to get the window rect directly, the returned value indicates a box of zero size, while the parent call returns legitimate values. Likewise, CallingSetWindowPos with on the parent actually moves the window (not off of the screen, unfortunately), but also adjusts it's size.
|
|
|
|
|
rentzk wrote: These articles mention the need to get the parent in order to access the various buttons on the dialog and change it's size.
That does not sound correct, all dialog controls are children of the dialog window not its parent. Perhaps you would be better to create your own dialog which is derived from CFileDialog ; see here[^] for further information.
rentzk wrote: When I try to get the window rect directly, the returned value indicates a box of zero size, while the parent call returns legitimate values.
Unfortunately I cannot reproduce this eactly as I do not have MFC on my system. However when I tried a similar test via a Win32 application I was able to get the size and position of my dialog, and move it to a different point on the screen independent of its parent. That would suggest to me that the same is possible with an MFC class dialog.
rentzk wrote: Likewise, CallingSetWindowPos with on the parent actually moves the window (not off of the screen, unfortunately), but also adjusts it's size.
And so it should, SetWindowPos should work for any window.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
It would appear that CFileDialog contains a function called OnInitdone. The base class for this function contains nothing more than a CenterWindow call, which has been taking all of my work and throwing it away. Overriding this function and not centering the dialog has everything working correctly, with the dialog being placed on whatever monitor I wish.
|
|
|
|
|
First time poster and newbie.
I have 2 computer systems sitting in 2 different locations. I want to retrieve files from one system to another. Sometime, the traffic is the other way round. Secure access is a concern of mine.
Ideally, to access the target location, I need to provide the IP address and port number. Are these the typical identifications for a remote site?
Also, if security is not compromise, I would like the connection between these 2 locations up for at least 6~12 hours at a time.
Is this a typical Client/Server project? Or this is a sFTP project? or something else altogether?
Can anyone kindly suggest relevant sample project in CodeProject so that I can learn by example from scratch?
I only know how to program in C/C++ in Windows environment.
Thanks in advance.
|
|
|
|
|
|
Thanks. Been to Wiki and there are 4~5 sample apps in CodeProject as well.
Is Peer-to-Peer file transfer method safe? Or it is as safe (or as vulnerable) as the socket layer underneath it?
The files that need to be transfer between the 2 system requires secure connection by law (medical).
From Wiki, Peer-to-Peer operates differently from client-server model. What is the difference between Peer-to-Peer and cloud computing?
Regards,
S
|
|
|
|
|
seifwen wrote: Is Peer-to-Peer file transfer method safe? Or it is as safe (or as vulnerable) as the socket layer underneath it?
The P2P networking model is only as safe as the underlying transport being used... e.g. use a standard TLS library for secure TCP connections. If properly integrated into your application (automatic certification handling or manual validation, etc), this should be able to fulfil requirements for a medical project.
seifwen wrote: Peer-to-Peer operates differently from client-server model.
Yes, they are pretty much the opposite. In a P2P network every node can be client or server (in theory), information/services can be distributed and provided from multiple sources, no centralised architecture.
seifwen wrote: What is the difference between Peer-to-Peer and cloud computing?
Cloud computing is a buzzword to describe an application/business model with a tendency towards client-server model, as far as I understand. On the other hand, P2P is a technical term to describe a networking model (P2P can be part of a cloud's networking architecture, however not typically used).
Hope those answers helped.
|
|
|
|
|
Thank you very much for your explanations. 
|
|
|
|
|
I am enabling my LAN connection using the code:
try
{
bool result = false;
typedef void (__stdcall * LPNcFreeNetconProperties)(NETCON_PROPERTIES* pProps);
HMODULE hmod = LoadLibrary(L"netshell.dll");
if (!hmod)
return false;
LPNcFreeNetconProperties NcFreeNetconProperties = (LPNcFreeNetconProperties)GetProcAddress(hmod, "NcFreeNetconProperties");
if (!NcFreeNetconProperties )
return false;
INetConnectionManager * pMan = 0;
HRESULT hres = CoCreateInstance(CLSID_ConnectionManager,
0,
CLSCTX_ALL,
__uuidof(INetConnectionManager),
(void**)&pMan);
if (SUCCEEDED(hres))
{
IEnumNetConnection * pEnum = 0;
hres = pMan->EnumConnections(NCME_DEFAULT, &pEnum);
if (SUCCEEDED(hres))
{
INetConnection * pCon = 0;
ULONG count;
bool done = false;
while (pEnum->Next(1, &pCon, &count) == S_OK && !done)
{
NETCON_PROPERTIES * pProps = 0;
hres = pCon->GetProperties(&pProps);
if (SUCCEEDED(hres))
{
if (wcscmp(pProps->pszwName,wszName) == 0)
{
if (bEnable)
result = (pCon->Connect() == S_OK);
else
result = (pCon->Disconnect() == S_OK);
done = true;
result=true;
}
NcFreeNetconProperties(pProps);
}
pCon->Release();
}
pEnum->Release();
}
pMan->Release();
}
FreeLibrary(hmod);
return result;
}
The code works fine for winXP but this is not having any effect when I run the same code in win7.
The function returns successfully but there is no effect on my LAN, it remains disabled.
I am not able to figure out where I am committing any mistake.
Thanks and regards,
Manoj
|
|
|
|
|
I've never heard of an Ian connection... Ian, what is this? lol
As to seriously answering the question, sorry, I can't.
|
|
|
|
|
Oops..must be a typing mistake.
|
|
|
|
|
Most likely Windows 7 requires administrator privilege to enable/disable the lan. Try to right-click on your executable and select "Run As Administrator" and see if that helps.
Good luck.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Sorry for my late reply..was out on the weekend.
I am running the code in my administrator account only but no changes to my LAN connection occur after it. It remains disabled.
Thanks,
Manoj
|
|
|
|