|
Hamid. wrote: But I cant see his monitor.
Spy eye can help!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
But I use of it at the other place how could you discover it?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
don't know.. what about programming it again
|
|
|
|
|
Hi Guys,
What's up!!!
I'm trying to figure out how to get the desktop resolution of the active user from the system account.
The situation is something like this -
I have a custom print processor (One of the print spooler components) that runs in the context of the SYSTEM account. I need to get the desktop resolution of the user who gave the print command in order to do some image processing on an EMF file. So it doesn't matter how many users have logged-in to the machine.
I tried using WTSEnumerateSessions /WTSQuerySessionInformation . This only works if you are using a remote session (mstsc.exe) and not for a normal session.
My alternate solution for this would be to spawn some process in the user context (Don't know how) and get the desktop resolution to the registry from where it could be read in the SYSTEM context.
But I was wondering if there was a cleaner way to achieve this.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Im in two minds/tracks of thought ..
1 goes .. use EnumDisplayDevices, EnumDisplaySettings, the other goes get/use WinSta0 and get the user session/desktop through that, but, Im begining to think thats useless/impractical
sorry ..
|
|
|
|
|
I am currently working on an application using C++ and MFC. The current state of my Menu's is that they are pull down only. That is, there are no icons on the top of the window. I would like to add icon's to the top of my window. What is the best way of doing this? Can the standard class CMenu do this? Does it make sense to use the class CMFCMenuBar?
Bob
|
|
|
|
|
BobInNJ wrote: That is, there are no icons on the top of the window
Do you mean there's no toolbar[^]?
If so, you probably want a CToolbarCtrl[^]. You probably want to look at this page[^] as well.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have Visual Studio 2005. I'm doing some console programming and developing a virtual computer store. I have a few problems.
1.) Why do I get these warnings?
Warning 1 warning C4996: 'strcat' was declared deprecated f:\testing\testing\testing.cpp 22
Warning 2 warning C4996: 'strcpy' was declared deprecated f:\testing\testing\testing.cpp 26
2.) You have to enter a password in the beginning of the program in order to access the store. I have it set up so that it tells the user that the password is incorrect. It used to display that if the user did indeed put in the wrong password but it would still let the user move onto the store. So to stop that, I added the line "return 0;" in the else condition. The problem is that it now exits out of the program without even letting the user see that the password was incorrect. What would be a better solution?
3.) I've noticed that in the first question if my if condition is true, it still moves onto my switch method question. I want it to stop.
Here is my code:
#include "stdafx.h"
#include "iostream"
using namespace std;
int main(){
char Password[50];
int a;
int b;
int c;
int d;
cout << "Type in the password to enter this promotional store of great savings.\n";
cin.getline(Password,50,'\n');
if (!strcmp(Password,"savings"))
{
strcat(Password," is the correct password!\n");
}
else
{
strcpy(Password,"That's not the correct password!\n");
return 0;
}
cout << Password;
cout << "Welcome to PC Warehouse\nHow much are you willing to spend?\n";
cin >> a;
if (a < 800){
cout << "Get out!\n";}
else {
cout << "How much RAM?\n";
cin >> b;}
if (b < 512){
cout << "I hope you're not planning on running Vista!\n";}
else {
cout << "Ok...how much HDD space?\n";
cin >> c;}
cout << "Ok, which videocard do you want?(Enter the number)\n1 Radeon X1600\n2 GeForce 8800\n3 Radeon HD 2600 XT\n";
cin >> d;
switch (d){
case 1:
cout << "Going cheap, no problem.\n";
break;
case 2:
cout << "Now we're talking...\n";
break;
case 3:
cout << "ooooof, you're going to need some power\n";
break;
default:
cout << "Invalid answer. Type in only the number of the corresponding videocard!\n";
break;
}
system("pause");
}
|
|
|
|
|
Under the rules of C++ all functions must be declared or defined before use. In the case of strcat,
you did not declare or define it. Under the old rules of C, if a function was not declared or
defined then the compiler assumed that it returned int. They way I would declare strcat, since it is a standard header file is to include the header file: string.h. Inside that header file there should be a declaration for strcat. There is a similar issue for strcpy.
To address the second issue, you might want to use a while loop. For example, your code might look
like the following:
<br />
bool validPassword = false;<br />
while ( validPassword == false ) {<br />
read password<br />
if password is correct then<br />
validPassowrd = true;<br />
else {<br />
put up error message<br />
}<br />
}<br />
Now, what I wrote about is not valid C++ but it should give you an idea of how you might restructure your program. I hope this helps. Feel free to ask a follow up question.
Bob
|
|
|
|
|
Ryuk1990 wrote: 1.) Why do I get these warnings?
Warning 1 warning C4996: 'strcat' was declared deprecated f:\testing\testing\testing.cpp 22
Warning 2 warning C4996: 'strcpy' was declared deprecated f:\testing\testing\testing.cpp 26
Because Microsoft decided they were unsafe and you should use strcat_s[^] and strcpy_s[^] instead. See this page[^] for even more detail.
Ryuk1990 wrote: 2.) You have to enter a password in the beginning of the program in order to access the store. I have it set up so that it tells the user that the password is incorrect. It used to display that if the user did indeed put in the wrong password but it would still let the user move onto the store. So to stop that, I added the line "return 0;" in the else condition. The problem is that it now exits out of the program without even letting the user see that the password was incorrect. What would be a better solution?
Replace
strcpy(Password,"That's not the correct password!\n");
with
cerr << "That's not the correct password!\n";
I'd also replace this
strcat(Password," is the correct password!\n");
with
cout << Password << " is the correct password!\n";
and get rid of this
cout << Password;
Ryuk1990 wrote: 3.) I've noticed that in the first question if my if condition is true, it still moves onto my switch method question. I want it to stop.
Put a return 0; after this line:
cout << "Get out!\n";}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm coding in C++ on Visual Studio 2005. I was working on a dialog-based MFC program the other night. I just opened it and I can't figure out how to view the design. I remember in VB.NET you just had to go to the top, select view, and then select view design. I don't see an option for that on C++.
|
|
|
|
|
Ryuk1990 wrote: design
Design? Do you mean a class diagram (in which case, I don't think C++ supports that) or the dialog layout (in which case, open the resource view, find the relevant dialog and double-click on it)?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Yeah, I wanted the dialog layout. Thank you.
|
|
|
|
|
An agent moves into a space which is composed of several corridors in three related
intersection of T-shaped, labeled S1, S2 and S3.
Crossroads s1 and S2 are corridors to the east, south and west; intersection s3 are corridors to the east, north and west. Each intersection agent are 2 possible actions: left or right. Actions
are Deterministic. If an agent reaches the wall (deadend) Teleport is instantly in
intersection point S3 and the girl from the south. Thus, the only possible choice of agent is
when you reach one of the 3 intersections and in front of the wall in T. The intersection
terms of a learning algorithm by reward, the 3-point selection are the 3 states of the environment. Trazitiile matrix with the states of the agent is given in table 1.
Immediate reward is given in table 2. Immediate reward can be interpreted as a
negative amount of reward for every meter of the route corridor to the last point
plus a selection of reward on teleportare (R and P).
To write a program that:
- Determine value pairs state-action optimal (Q-learning) and it shows;
- Extract a policy of optimal state-action pairs and thus show:
Status Worldwide | Action Selected cf optimal policy
s1 |
S2 |
s3 |
|
|
|
|
|
so whats your problem ?
you're not expecting US to write your code for you are you ?
you could start reading here http://www-anw.cs.umass.edu/rlr/domains.html[^] for example and you might get some hints from some of those examples
'g'
|
|
|
|
|
I have downloaded many Global Keyboard and Mouse Hook programs. The mouse hook works perfectly. The keyboard hook works for a few seconds. If I take some time after hooking the keyboard to press a key, the program fails to capture that key. If I am fast enough to start the program and pressing one or more key, the program captures a few of them and stops after a little while.
I have uninstalled my virus/spyware protection and the same thing occurs. It must be something wrong in my enviroment (Windows XP) since this happens with all the global keyboard hook programs I have tested. Any hints?
Thank you!
Mario
Mcfonseca
|
|
|
|
|
Hello Friends!!!
I create a progress bar in the status bar. But that's a still something wrong. The progress bar which should occupied the pane rectangle fail to cover all the rectangle but leave some part uncovered, I can see the progress on the surface and the end part of the IDS_PROGRESS string text uncovered. I don't know how to correct it. If your can offer some help, I will really appreciate it. thanks!
I post the code as follows:
<br />
BOOL CMainFrame::CreateStatusBar()<br />
{<br />
static UINT nIndicators[] = {<br />
ID_SEPARATOR,<br />
IDS_PROGRESS,
IDS_TIMER,
IDS_INDICATOR_POS,
ID_INDICATOR_LINE,
ID_INDICATOR_CAPS,<br />
ID_INDICATOR_NUM<br />
};<br />
<br />
if (!m_wndStatusBar.Create (this))<br />
return FALSE;<br />
<br />
m_wndStatusBar.SetIndicators (nIndicators, 7);<br />
return TRUE;<br />
}<br />
<br />
<br />
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
EnableDocking (CBRS_ALIGN_ANY);<br />
<br />
if (!CreateToolBar () ||<br />
!CreateStyleBar ()||!CreateStatusBar())<br />
return -1;<br />
LoadBarState (_T ("MainBarState")); <br />
<br />
<br />
CRect rect;<br />
m_wndStatusBar.GetItemRect(1,&rect);<br />
m_Progress.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH,rect,&m_wndStatusBar,IDS_PROGRESS);<br />
<br />
<br />
SetTimer(ID_TIME,500,NULL);
return 0;<br />
}<br />
<br />
<br />
void CMainFrame::OnPaint() <br />
{<br />
CPaintDC dc(this);
<br />
if(m_Progress.GetSafeHwnd() != NULL)<br />
{<br />
CRect rect;<br />
m_wndStatusBar.GetItemRect(1,&rect);<br />
m_Progress.MoveWindow(rect); <br />
}<br />
}<br />
<br />
<br />
void CMainFrame::OnTimer(UINT nIDEvent) <br />
{<br />
CTime time=CTime::GetCurrentTime();<br />
int nHour=time.GetHour()%12;<br />
int nMinu=time.GetMinute();<br />
int nSecond=time.GetSecond();<br />
<br />
CString str;<br />
str.Format(_T("%0.2d:%0.2d:%0.2d"),nHour,nMinu,nSecond);<br />
if(m_wndStatusBar.GetSafeHwnd() != NULL)<br />
{<br />
CClientDC dc(this); <br />
CSize sz=dc.GetTextExtent("22:22:22");<br />
m_wndStatusBar.SetPaneInfo(2,IDS_TIMER,SBPS_NORMAL,sz.cx);<br />
m_wndStatusBar.SetPaneText(2,str); <br />
}<br />
<br />
if(m_Progress.GetSafeHwnd() == NULL)<br />
{<br />
CRect rect;<br />
m_wndStatusBar.GetItemRect(1,&rect);<br />
m_Progress.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH,rect,&m_wndStatusBar,IDS_PROGRESS);<br />
m_Progress.SetRange(0,100);<br />
m_Progress.SetPos(0);<br />
}<br />
m_Progress.StepIt();<br />
<br />
CFrameWnd::OnTimer(nIDEvent);<br />
}<br />
<br />
|
|
|
|
|
Hi,
I have been reading a essay By Joseph Newcomer re: Threading CasyncSockets
KB192570
In the essay he notfies the Dialog about the completion of send/receive via
Postmessage
I noticed that the Dialog Class CAsyncClientDlg
has the functions declared to receive the messages However there aren't any message Map
entries
Do I have to have a Message map entry when Sending/Posting a message to a CWnd???
Thankx
|
|
|
|
|
|
The way I understand the Doc
SendMessage Calls The WndProc associated with CWnd so.......
When Get Notfication from CAsyncSocket e.h. OnConnect
I dont have any message map entries
thankx Again
SendMessage
Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.
|
|
|
|
|
Message map is an MFC technique to map a message to a function.
If you application is NON-MFC you would simply have a large switch statement in which you would handle the message that is being sent by SendMessage /PostMessage .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I was just wondering if CWnd::Sendmessage
e.g. for a user message needs a nessage map entry
As in Order to get CAysncSocket's OnReceive
you down need a message nap entry to get OnReceive
notifications
|
|
|
|
|
|
And your question is?!
Oh, and by the way, if you do ask a question, don't just post a link to your complete project - post the code fragment you're having trouble with!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
What the hell is wrong with you? You've been posting this mindless drivel for a while now. Your employer has my sympathy.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|