|
Hello,
Finally I choose to play with GDI .
So I use these pDC->MoveTo(Startx, z) and pDC->LineTo((Startx + LTot), z) to draw the grid and these pDC->GetTextExtent(C61Title[0]) and pDC->TextOut(a, b, C61Title[0]) to put my value in the grid.
Now, in order to better differenciate the titles from the values, I would like to fill in grey the cells before writting my titles in ... do you have an idea of how I can do this ?
Thanks in advance
DD
|
|
|
|
|
When building an application, should I create a .cpp for every header file in which a class is defined, even if all the implementation resides in the header file? What are the inconvenients and advantages of doing - or not doing - this?
I'm asking because I've started a rather large project, and I have several classes implemented in their respective header files - 4x4 matrix, 3d vector classes, etc., to allow for their respective methods to be inlined. But since header files cannot be compiled, I have to include these headers in a .cpp to allow for compilation. But is it really worth it, since the .cpp contain nothing but an inclusion? Should I remove these files when I start actually creating objects in my application?
Cheers, blackmesa.
|
|
|
|
|
Generally speaking, only templates are implemented in header files only. Sometimes, if the classes are small and contain no static data, then the whole implementation may very well reside in the header file.
If the cpp file only contains an inclusion, then just remove it.
--
You're entertaining at least.
|
|
|
|
|
Hi, ive got this problem :
when i use this everything is ok :
LPHOSTENT hostent;
hostent = gethostbyname("localhost");
but with this :
LPHOSTENT hostent;
CString strIP="127.0.0.1"
hostent = gethostbyaddr (strIP,strIP.GetLength (),AF_INET);
i cant connect to the server (of course it does the same with other adresses then localhost
Can u tell me plz what im doing wrong ? And the third para in gethostbyadd. Does it have to be always AF_INET or there are some choices?
Thx in Advance.
|
|
|
|
|
What does WSAGetLastError() return after the failed call to gethostbyaddr() ?
--
You're entertaining at least.
|
|
|
|
|
unsigned long ulResult = inet_addr(strIP);
if (INADDR_NONE != ulResult)
{
hostent = gethostbyaddr((char *) &ulResult, sizeof(ulResult), AF_INET);
}
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thanks
|
|
|
|
|
How to pass variable to Windows System?
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
char comp_name [20];
system("cls");
cout << "Please enter computer name: " ;
cin >> comp_name;
system("del \\comp_name\c$\WINNT\MS\SMS\CORE\BIN\SlowNet.exe");
return 0;
}
How can I pass comp_name to Windows command?
Thank you.
|
|
|
|
|
You need to construct the string correctly - what you're doing is trying to call system with a string literal - which doesn't take what you set comp_name to into account (here's a question for you, what would your "code" do if you had a variable called WINNT? )
What you need to do is construct a std::string with the relevant computer name:
string command_to_do;
command_to_do = "del \\";
command_to_do += comp_name;
command_to_do += "\c$\WINNT\MS\SMS\CORE\BIN\SlowNet.exe"
system(command_to_do.c_str());
(Untested code, so your milage may vary)
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
A \\ in the hand is worth more than a \ in the string.
--
You're entertaining at least.
|
|
|
|
|
Anonymous wrote:
system("del \\comp_name\c$\WINNT\MS\SMS\CORE\BIN\SlowNet.exe");
Lose the system() command and use DeleteFile() instead.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
How to pass variable to Windows System?
code:--------------------------------------------------------------------------------
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
char comp_name [20];
system("cls");
cout << "Please enter computer name: " ;
cin >> comp_name;
system("del \\comp_name\c$\WINNT\MS\SMS\CORE\BIN\SlowNet.exe");
return 0;
}
--------------------------------------------------------------------------------
How can I pass comp_name to Windows command?
Thank you.
|
|
|
|
|
The Copy Hook Handlers only can be used to approve the file operation, but are not informed of the success or failure of the operation. So they cannot be used to monitor file operations. Is there anyone can tell me how can I do it?
|
|
|
|
|
|
Ravi,
Thanks for your reply. It is very helpful.
Shaomin
|
|
|
|
|
Here's my problem:
I have 2 radio buttons in my dialog-based MFCAppWizard-made application (first radio button has "Group" property and is mapped to m_Operation). Their names are: "Encode" and "Decode"
By default (in OnInitDialog) I select the first radio button (otherwise none would be selected at startup) with:
m_Operation = 0;
I have 2 Static Text controls (IDC_SOURCE and IDC_DESTINATION) both mapped thru ClassWizard to m_Source (CString type) and m_Destination (CString also)
At a certain point the user selects a file and the app will write something to m_Source:
m_Source = "C:\\MyFile.txt";
But that won't make it visible in the main form so I:
UpdateData(FALSE);
And it becomes visible. But MY PROBLEM IS THAT IN THAT MOMENT THE RADIO BUTTON SELECTION SCREWS UP.
How is that? If "Decode" was selected before UpdateData(2nd radio button - "1") then "Encode" will become selected (1st radio button - "0").
HOW CAN I AVOID THIS? Not calling UpdateData or UpdateData() or UpdateData(TRUE) will cause this: m_Source = "C:\\AnyFile.txt"; does not update visually the static text control in my app.
Please help?!
Andrei Rinea
|
|
|
|
|
Associate a CStatic object with static text control and call staticobj.SetWindowText("text") to change the text of static control instead of calling UpdateData
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
andreir23 wrote:
But MY PROBLEM IS THAT IN THAT MOMENT THE RADIO BUTTON SELECTION SCREWS UP.
How is that? If "Decode" was selected before UpdateData(2nd radio button - "1") then "Encode" will become selected (1st radio button - "0").
HOW CAN I AVOID THIS? Not calling UpdateData or UpdateData() or UpdateData(TRUE) will cause this: m_Source = "C:\\AnyFile.txt"; does not update visually the static text control in my app.
Which is why UpdateData() should be used as little, if at all, as necessary. Use member control variables instead.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Allrighte...
But if I don't use that darn UpdateData, I CANNOT UPDATE the static text.
Let me put the problem in a simpler manner:
You have a static text (in Delphi it was called "Label")
How do you modify its content and then update it visually so the darn thing on the screen reflects what you wrote in it?!
I mean I mapped thru ClassWizard a CString to that static text control named m_Source.
If I just say
m_Source = "My text!!";
nothing on the screen changes. Especially that darn static text.
How exactly do you recommend me to do it?
TIA!
|
|
|
|
|
andreir23 wrote:
I mean I mapped thru ClassWizard a CString to that static text control named m_Source.
Dont map a CString to that static text control. Map a CStatic to that static text control m_source( Just select Control in the combobox where u map a variable, it will autmatically show CStatic in the datatype field)
Now if u just want to change the text of static control, and want other controls like radio to remain unchanged, just call this function
<br />
m_source.SetWindowText("My Text!!");<br />
It will modify its contents and update it visually.. Now to retrieve the text from static control call
<br />
CString str;<br />
m_source.GetWindowText(str);<br />
OR
U can also use
<br />
SendMessage(m_source.GetSafeHwnd(),WM_SETTEXT,(WPARAM)0,(LPARAM)"My Text"); <br />
to achieve the same task *visually updating static text without chaning any
other control.
This will definately solve your problem..
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
Add a handler for BN_CLICKED for each of your radio buttons. In the handler, set the m_Operation member to the button that was just clicked. It isn't otherwise being updated, which is why it reverts to the old setting when UpdateData(FALSE) is called.
void CDlgtestDlg::OnRadio1()
{
m_Radio = 0;
}
void CDlgtestDlg::OnRadio2()
{
m_Radio = 1;
}
or you can add a single handler for this using ON_CONTROL_RANGE(BN_CLICKED ...)
Nick
This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2003 Microsoft Corporation. All rights reserved.
|
|
|
|
|
Hello all.
I can't seem to find this anywhere, but I do remember at some point in time I've used this in c, for printf.
What I'm basically trying to do is conditionally format my sprintf() statement to display an "s" character if an integer is greater than one.
Sort of like this:
if (x>1) {
sprintf(buf,"%d files processed",x);
} else {
sprintf(buf,"%d file processed,x);
}
Except I do not wish to use an if statement like that.
I remember somewhere that you can do this with some sort of printf(...? i>1...); I remember it had something to do with a question mark in there but that's all I can remember. Unfortunately a google search of "printf ?" doesn't seem to help me out.
|
|
|
|
|
You're thinking of a lisp statement.
printf(buf,(x > 1 ? "%d files processed" : "%d file processed"),x);
conditional ? true : false
Hope this helps,
Tyler Kellen
|
|
|
|
|
<br />
int i=5;<br />
int j=6;<br />
printf("Hello %d", i>0?i:j);<br />
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
int i=5;
int j=6;
printf("Hello %d", i>0?i:j);
hahahaha
Programming is an art not a skill, every one can be a skilled programmer but not an artist.
|
|
|
|