|
im trying to figure this sucker out, the idea i want to do is notify user MessageBox("hifile changed") when the file "1.txt" has been edited, but this hole FileSystemWatcher.OnChanged seems confusing, can anyone give me any suggestions or tutorials or examples? would be great!
thanks!
|
|
|
|
|
|
|
hai,
I am working on VC++ win32.I am creating a timer that decrements a counter every second(in Dlg Procedure).I have class where I have to reset the value of the timer.I am thinking of how to do this?
ie.
//main.cpp
int g_counter = 10;
main()
{
///here i decrement the timer every second
}
// myclass.cpp
int myclass::myfunction()
{
///here i want to set g_counter = 10;////how should i exactly do it..
}
|
|
|
|
|
manu81 wrote:
///here i decrement the timer every second
What function are you using to establish the timer?
manu81 wrote:
///here i want to set g_counter = 10;////how should i exactly do it..
You mean besides:
g_counter = 10;
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi i'm having difficulties, kinda fresh in C++ and I want to know how to do this code in C++:
"Dim name As String"
anyone tell me how to do it in C++ please
|
|
|
|
|
The answer is: it depends.
In simplest 'C' terms (which also works for C++), strings are arrays of characters:
char str[128];
strcpy(str,"This is a string"); defines a string str . Strings are terminated by a 0 byte, which marks the end of the string. In order to set the string, or assign one string to another, you have to call a function like strcpy .
If you are using Microsoft Visual C++ and the MFC (Microsoft Foundation Class) library, you've got a class called CString :
CString str;
str = "This is a string"; CString makes using strings a lot easier than the 'array of characters' approach. Instead of having to call functions to do simple operations like assigning one string to another, you can use a simple assignment:
CString str1("This is string 1");
CString str2("This is string 2");
str1 = str2; CString also defines the '+' operator for doing string concatenation, along with others.
The Standard Template Library (STL) defines a string class as well. I'm not familiar with the STL, but you should be able to find examples.
Software Zen: delete this;
|
|
|
|
|
Read tutorials....
Don't try it, just do it!
|
|
|
|
|
To add text to the end of an edit box, why doesn't this work? SendMessage(hEditWnd,EM_SETSEL,0,MAKELONG(0xffff, 0xffff));
thats now MSDN tells you to do it
wWw.KruncherInc.cOm
|
|
|
|
|
The EM_SETSEL message sets the selection for the control. Using the parameters you've supplied (0 and 0xFFFFFFFF) tells the control to select all of the text it contains.
The standard edit control doesn't support appending text to its current contents. You can only 'get' the entire text of the control, or 'set' it.
By the way: You don't need to use MAKELONG(0xffff,0xffff) for the final parameter. You can just use 0xFFFFFFFF .
Software Zen: delete this;
|
|
|
|
|
First put the insertion point (i.e., caret) at the end of any text using EM_SETSEL , then use EM_REPLACESEL to append the text.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
How can I make,
LPCTSTR strText
to a CString?
Please help me.
|
|
|
|
|
Just assign to a CString variable, the CString constructor will handle the rest.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
|
|
|
|
|
Thanks,
There is one more thing,
In my base class I have some private code and when I try to get to them by caling it from anather class like this.
dlg_Main->UserLogin(sMsg);
And when I get to that funktion it don't work what I am doing wrong?
|
|
|
|
|
This is the error I get!
CListBox hWnd=???
|
|
|
|
|
Hi there!
could u pls show me the part of your code, where you are facing problem.
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
When I try to open the resource file (.rc) using the Resource Editor in Visual Studio .NET, I get an error telling me "opened in another editor". I did a little digging and I think this file is saved as UNICODE. I tried to save as US-ANSI but that did do anything? Might anyone know what this is and how to fix it?
Thanks!
|
|
|
|
|
You will see this message if you open the .rc file (or the resource.h file) in the text editor, and then try to edit the resources using the resource editor.
Note that .rc files will not compile when saved as UNICODE.
Another thing to try is to delete the file named <project>.aps in your project directory. This file is used by the IDE to store a parsed version of the .rc file while you are using the resource editor. It's not uncommon for this file to get messed up. Deleting it is harmless, as the IDE will recreate it as needed.
Software Zen: delete this;
|
|
|
|
|
The rc files are opened anywhere else. they opened before but that was a while ago. A lot could have changed, but I never remember saving them as unicode unless it happened on accident. I tried deleting the .aps file. Nothing seemed to happen. I tried, rebooting the machine, closing the application. Every .rc file will not open for my project.
that is too weird.
|
|
|
|
|
I managed to fix the issue by reinstalling Visual Studio.
Thanks for the help!
|
|
|
|
|
Why does the output of driver.get_name() display a number instead of the string of characters passed to driver.set_name() ?
I've not done C++ in quite some time so any help would be great.
Thanks in advance.
code:
///////////////// from .cpp file ///////////////
details driver;
driver.set_name("abc");
cout << "name = " << driver.get_name() << endl;
///////////////////////////////////////////////////////////
/////////////////////// the class /////////////////////////////////////////
#ifndef DETAILS_H
#define DETAILS_H
class details
{
public:
int get_name();
int get_grade();
void set_name(char name[3]);
void set_grade(int the_grade);
private:
int name[3];
int grade;
};
int details::get_name()
{
return name[3];
}
int details::get_grade()
{
return grade;
}
void details::set_name(char the_name[3])
{
name[3] = the_name[3];
}
void details::set_grade(int the_grade)
{
grade = the_grade;
}
#endif
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
As I see you don't have any knowledge or experiences on programming!
You made a critical mistake which normally won't happen if you had experience in programming in general.
you defined:
int name[3];
that means, that the "name" array has 3 indexes... 0, 1, 2
return name[3]; or name[3] = the_name[3]; <- this will never work because index 3 is not part of the array.
in some cases this can be very critical. Exploits often work by using software errors to write on memory areas not being part of the array.
Don't try it, just do it!
|
|
|
|
|
Alexander, thank you so much for your reply. I see exactly what I did wrong. When I realised I had the index at the wrong size it printed a number out instead of the char. I had the return type as int so it must've been casting the char to an int.
If I wanted to store a string of chars would I better declaring them as a string or sticking with an array? If I stick with an array I would need to loop round the array to display all the array elements, is there a better/neater way to do it?
Cheers in advance for any tips.
Graeme
|
|
|
|
|
This is my dtio.h file and after that is the dtio.c file
/**********************************************************
* dtio.h - header file for direct-terminal I/O functions *
* supporting both Borland C and AIX cc platforms *
**********************************************************/
#ifndef _dtio_h_
#define _dtio_h_
#define BORLANDC 1
#define AIXC 2
/* change the following line to support one of the above */
#define PLATFORM AIXC
/* some platform-dependent keys (obtained by experimentation) */
#if PLATFORM == AIXC
#define ENTER_KEY 10
#define UP_KEY 1859
#define DOWN_KEY 1858
#define LEFT_KEY 1860
#define RIGHT_KEY 1861
#define PGUP_KEY 1939
#define PGDN_KEY 1938
#define TAB_KEY 9
#define BS_KEY 8
#define DEL_KEY 1930
#define HOME_KEY 1862
#define END_KEY 1860
#define ESC_KEY 27
#define INS_KEY 1931
#define F1_KEY 1865
#define F2_KEY 1866
#define F3_KEY 1867
#define F4_KEY 1868
#define F5_KEY 1869
#define F6_KEY 1870
#define F7_KEY 1871
#define F8_KEY 1872
#define F9_KEY 1873
#define F10_KEY 1874
#else
#define ENTER_KEY 13
#define UP_KEY 1072
#define DOWN_KEY 1080
#define LEFT_KEY 1075
#define RIGHT_KEY 1077
#define PGUP_KEY 1073
#define PGDN_KEY 1081
#define TAB_KEY 9
#define BS_KEY 8
#define DEL_KEY 1083
#define HOME_KEY 1071
#define END_KEY 1079
#define ESC_KEY 27
#define INS_KEY 1082
#define F1_KEY 1059
#define F2_KEY 1060
#define F3_KEY 1061
#define F4_KEY 1062
#define F5_KEY 1063
#define F6_KEY 1064
#define F7_KEY 1065
#define F8_KEY 1066
#define F9_KEY 1067
#define F10_KEY 1068
#endif
void dt_start(void); /* initializations for dt routines */
void dt_stop(void); /* shutdown of dt routines */
int dt_rows(void); /* find # of rows of screen */
int dt_columns(void); /* find # of columns of screen */
void dt_clear(void); /* clear screen */
void dt_flush(void); /* flush any un-written output */
int dt_getchar(void); /* get one key press */
void dt_cursor(int row, int column); /* move cursor */
void dt_putchar(int c);/* output one character */
void dt_puts(char *s); /* output a string */
void dt_display(const char *s, int row, int column, int length);
int dt_edit(char *s, int row, int col, int flen, int slen, int *ppos,int *poff);
#endif /* end _dtio_h_ */
*************************************************************
This is the dtio.c file:
/**********************************************************
* dtio.c - direct-terminal I/O functions supporting both *
* Borland C and AIX cc platforms. A program that *
* wants to use these should: #include "dtio.h" *
**********************************************************/
#include "dtio.h"
#if PLATFORM == AIXC
#include <curses.h>
#else
#include <conio.h>
#endif
/* Initialize. Note that Borland version does nothing. */
void dt_start(void)
{
#if PLATFORM == AIXC
initscr();
noecho();
cbreak();
keypad(stdscr, 1);
#endif
}
/* Shutdown */
void dt_stop(void)
{
#if PLATFORM == AIXC
refresh();
endwin();
#else
/* we don't want the cursor left in the
middle of a screen. AIX's endwin() handles
this for us, but on the PC we must take care
of this. Clearing the screen is an easy way. */
clrscr();
#endif
}
/* Return number of screen rows */
int dt_rows(void)
{
#if PLATFORM == AIXC
return LINES;
#else
struct text_info x;
gettextinfo(&x);
return x.screenheight;
#endif
}
/* Return number of screen columns */
int dt_columns(void)
{
#if PLATFORM == AIXC
return COLS;
#else
struct text_info x;
gettextinfo(&x);
return x.screenwidth;
#endif
}
/* Clear screen */
void dt_clear(void)
{
#if PLATFORM == AIXC
erase();
#else
clrscr();
#endif
}
/* Bring screen up-to-date. Note that since dt_stop() and
* dt_getchar() both bring the screen up-to-date, programs
* will only have to call this if the screen must be brought
* up-to-date when a long pause (other than waiting for
* input) is expected.
*/
void dt_flush(void)
{
#if PLATFORM == AIXC
refresh();
#endif
}
/* Return one keystroke, bringing screen up-to-date first */
int dt_getchar(void)
{
#if PLATFORM == AIXC
refresh();
return getch();
#else
/* For extended keys in DOS, return 1000 + second key code */
int key;
key = getch();
return key == 0 ? 1000 + getch() : key;
#endif
}
/* Move cursor. (0, 0) is the upper-left corner */
void dt_cursor(int row, int column)
{
#if PLATFORM == AIXC
move(row, column);
#else
gotoxy(column + 1, row + 1);
#endif
}
/* Output one character at cursor location */
void dt_putchar(int c)
{
#if PLATFORM == AIXC
addch(c);
#else
putch(c);
#endif
}
/* Output character string at cursor location */
void dt_puts(char *s)
{
#if PLATFORM == AIXC
addstr(s);
#else
cputs(s);
#endif
}
void dt_display(const char *s, int row, int column, int length)
{
#if PLATFORM == AIXC
int length1=strlen(s);
#if length1 > length
for (i=0;i<length;i++)
{
addch(s[i]);
}
move(LINES,COLS);
#elif length1 < length
int space=length-length1;
addstr(s);
for (i=0;i<space;i++)
{
addch(' ');
}
move(LINES,COLS);
#elif length <= 0
addstr(s);
move(LINES,COLS);
#endif
#else
int length1=strlen(s);
struct text_info x;
gettextinfo(&x);
#if length1 > length
for (i=0;i<length;i++)
{
putch(s[i]);
}
gotoxy(x.screenwidth-1,x.screenheight-1);
#elif length1 < length
int space=length-length1;
addstr(s);
for (i=0;i<space;i++)
{
addch(' ');
}
gotoxy(x.screenwidth-1,x.screenheight-1);
#elif length <= 0
addstr(s);
gotoxy(x.screenwidth-1,x.screenheight-1);
#endif
#endif
}
int dt_edit(char *s, int row, int col, int flen, int slen, int *ppos,int *poff)
{
#if PLATFORM == AIXC
************************************************************
This is what is required please help me:
void dt_start(void)
initializes the full screen routines. This should be called before
calling any of the other "dt" functions (and may only be called once
before dt_stop() is called to stop using the full screen rountines).
void dt_stop(void)
shuts down the use of the terminal control routines, and ensures
that the cursor is not left in the middle of screen full of stuff.
Note that a program which has called dt_start() (defined above) must
call this function before terminating.
int dt_rows(void)
returns the number of rows on the screen.
int dt_columns(void)
returns the number of columns on the screen.
void dt_clear(void)
clears the screen, ensuring the cursor is in the upper left corner
when finished.
void dt_flush(void)
ensures that any full screen output which has been sent to the
screen actually gets there (i.e. this "flushes the output buffer").
int dt_getchar(void)
flushes screen output (if there is any pending output which has not
yet been displayed), waits for a key to be pressed and returns an
int value uniquely identifying the key pressed. Note that for
non-ASCII keys, the value for a key is system dependent, but the
following symbolic names should be set up appropriately (in dtio.h):
UP_KEY - the value for the up arrow key
DOWN_KEY - the value for the down arrow key
LEFT_KEY - the value for the left arrow key
RIGHT_KEY - the value for the right arrow key
PGUP_KEY - the value for the page up (or previous screen) key
PGDN_KEY - the value for the page down (or next screen) key
ENTER_KEY - the value for the enter (or carriage return) key
TAB_KEY - the value for the tab key
BS_KEY - the value for the backspace key
DEL_KEY - the value for the delete key
HOME_KEY - the value for the home key
END_KEY - the value for the end key
ESC_KEY - the value for the escape key
INS_KEY - the value for the insert key
F1_KEY, F2_KEY, ... F10_KEY - the values for the F1 through
F10 keys, respectively
void dt_cursor(int row, int column)
positions the cursor at the row and column specified, where row 0 is
the top row and column 0 is the left-most column. (Note that the
results are not defined if the row or column is invalid. Note also
that on systems where output is buffered, this function does NOT
flush the output buffer.)
void dt_putchar(int c)
outputs the character, with the ASCII code stored in "c", at the
current position on the screen. This function advances the cursor by
one position, although the results are system dependent if the
cursor is already at the right edge of the screen. (Note that on
systems where output is buffered, this function does not flush the
output buffer).
void dt_puts(const char *s)
outputs the null-terminated string pointed to by "s", starting at
the current position on the screen. Afterwards, the cursor position
is just after the last character that was displayed. The results are
not defined if the length of the string exceeds the available space
left on the current line of output. (Note that on systems where
output is buffered, this function does not flush the output buffer,
and that if the last character of the string appears on the last
column of the string, the position of the cursor will be system
dependent).
void dt_display(const char *s, int row, int column, int length)
outputs the null-terminated string pointed to by "s", in a field of
the screen starting at row "row" and column "column" of the screen,
for a length of "length" characters. As with dt_cursor, 0 is the top
row, and 0 is the leftmost column. If the string is longer than
"length", then only "length" characters are displayed, but if it is
shorter than "length", then the entire string is displayed, followed
by enough trailing spaces to fill out the field. However, if
"length" is 0 or less, then the field length is considered to be the
actual length of the string (i.e. the entire string is displayed).
Afterwards, the cursor is positioned after the last position of the
field. (Note that on systems where output is buffered, this function
does not flush the output buffer, and that if the last character of
the string appears on the last column of the string, the position of
the cursor will be system dependent). The results are undefined if
the specified values indicate a field which does not fit on the
screen.
int dt_edit(char *s, int row, int col, int flen, int slen, int *ppos,
int *poff)
allows the user to perform full screen editing of a null-terminated
string in a single-line field on the screen. The parameters are:
s - points to the string being edited.
row - the row of the screen for the field, where 0 is the top row
of the screen.
col - the starting column for the field, where 0 is the left-most
column of the screen.
flen - the length of the field in which editing is performed, or
0, in which case the initial length of "s" determines the
field length. Note that the field length determines the
maximum number of characters from the string that can be
displayed at the same time.
slen - the maximum possible length for the string, or 0, in which
case the field length is also the maximum string length. If
this is larger than the field length, then it will be
possible for the user to enter a string larger than what can
be displayed in the field, and so the string will have to be
"scrolled" as it it edited so that the position of the
cursor within the string will always be visible.
ppos - this is either NULL or it points to an int containing the
current position of the cursor within the field, where 0
means that the cursor is on the first position of the field.
If it is non-NULL, note that this parameter has two uses: it
determines the starting location of the cursor within the
field and it is used to communicate back to the calling
function where the cursor was when editing stopped.
If this parameter is NULL, the cursor initially is placed on
the first character of the field, and the calling function
will not be able to know where the cursor was when editing
stopped.
poff - this is either NULL or it points to an int containing the
index of the character from the string which appears in the
first position of the field, i.e. the offset by which the
string is scrolled.
If it is non-NULL, note that this parameter has two uses: it
determines the initial scrolling offset when editing starts
and it is used to communicate back to the calling function
how much the string was scrolled when editing stopped.
If this parameter is NULL, the first character of the string
is initially displayed in the first position of the field,
and the calling function will not be able to find out how
much the string was scrolled when editing stopped.
The cursor is never allowed to move before the start of the field or
more than one position past the last character in the string or the
field, whichever comes first. Additionally, in the case where the
field ends at the edge of the screen, the cursor is not allowed past
the edge of the screen.
Editing is terminated by pressing ENTER_KEY, TAB_KEY, ESC_KEY,
UP_KEY, DOWN_KEY, PGUP_KEY, PGDN_KEY or any of the function keys
F1_KEY to F10_KEY. (You may extend this to include all function
keys, if you wish). If ESC_KEY is used to terminate editing, then
editing is aborted - the string is left containing the data
originally passed to dt_edit(), the variables pointed to by ppos and
poff (if any) retain their original values, and the original string
value is redisplayed.
The function returns an int identifying the the key that was pressed
to exit. (This function uses the same key codes as dt_getchar()
above).
The function takes no action (other than perhaps beeping) if the
user tries to enter too many characters (if, for example, the string
is full in insert mode, or the cursor is positioned after the last
character of a full string in overstrike mode).
The function handles at least the following special keys:
LEFT_KEY - move left one character, if possible.
RIGHT_KEY - move right one character, if possible.
HOME_KEY - go to the beginning of the string.
END_KEY - go to the end of the data in the string, i.e. just
past the last character in the string. (If the last
character is at the edge of the screen, then END goes to
that character).
INS_KEY - toggle Insert/Overstrike mode (the default is Insert).
In Insert mode, printable characters are inserted into the
string, moving the remainder of the string to the right to
make room. In Overstrike mode, printable characters
overwrite existing characters (if any). Note that if you are
past the end of the string, printable characters are
appended to the string (as long as the string isn't full)
regardless of the mode. Also note that, regardless of the
mode, the cursor advances as printable characters are typed
into the string.
DEL_KEY - eat the current character and move all subsequent
characters one position to the left.
BS_KEY - move the rest of the string (including the cursor) one
position to the left, if possible, eating the previous
character.
Any normal printable key is simply placed into the string according
to the rules laid out in the discussion of the INS_KEY key above.
(The keys from the space character to the tilde character in the
ASCII table are considered "printable".)
The dt_edit() function always shows blanks in any the part of the
field that is not occupied by the data in the string. UNDER NO
CIRCMUSTANCES DOES THE FUNCTION CHANGE ANY POSITION ON THE SCREEN
OUTSIDE OF THE FIELD. For example, it is important that you don't
display status information (such as "INS" or "OVR") elsewhere on the
screen, since this will limit the programmer's ability to design
screen layouts.
Like most C library functions, your dt_edit() may assume that it is
the calling program's reponsibility to ensure that the array is
large enough to handle the specified number of characters, and that
the starting screen position provides enough room (on the screen)
for the field, etc.
Technical Note: in order to be able to restore the string to its
original value, you will need a backup copy of it. Since you won't
be able to predict the size of the string to be edited at compile
time, the only safe way to do this is by using dynamic memory
allocation. Investigate the functions strdup(), malloc() and free()
to learn how to do this in C.
These functions are to be declared in a file named dtio.h along with the
symbolic key codes mentioned above. The functions are to be defined in a
file named dtio.c. They should compile and work properly (according to
the specs above) in both the "Command Prompt box" under Windows (you may
use either the Borland C++ compiler or the Microsoft Visual C++
compiler, although you are on your own for technical help with Visual
C++), the AIX cc environment on phobos, and the Linux cc (gcc)
environment on matrix. At most one or two lines of dtio.h should need to
be modified when changing from one environment to another.
|
|
|
|
|
If you think that someone is going to read all this and answer you, then u r totally wrong. Try to be precise and tell the exact problem which you are facing. Copying whole file here is not an ideal thing to do.
Imagine that you are creating a fabric of human destiny with the object of making men happy in the end, giving them peace and rest at last, but that it was essential and inevitable to torture to death only one tiny creature..and to found that edifice on its unavenged tears, would you consent to be the architect on those conditions? Tell me, and tell me the truth!
-Fyodor Dostoevsky, The Brothers Karamazov
|
|
|
|
|