|
Hi
int k=0;
while(k<97)
{
printf("%c",'*');
k=K+1;
}
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hi, I've used Visual C++ for a couple of years, but I'm just learning MFC for C++ .Net right now.
Anyway, I'd like to be able to click a button that gives me a new dialog box (or just hides everything on the current one and gives me a box that looks new). Say I click on a 'stats' button. I'd then like to select from a 'stats' menu which kind of stats I would like to display, etc.
What would be the easiest or best way to accomplish what I'm trying to do in a MFC app?
Thanks,
Mark
|
|
|
|
|
CMyDialog::OnClickBtn()
{
//replace CDialog with your own Dialog class.
CDialog dlg;
dlg.DoModal();
}
There is no spoon.
mail
|
|
|
|
|
Thanks.
|
|
|
|
|
I want to be able to take an unsigned int, and use the 32 bits that make up that int for some further calculations.
Is there a way of doing this, via some library, or some built-in function???
|
|
|
|
|
http://www.codeproject.com/cpp/bitbashing.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
In the application I've created, I need to do the following:
1. Need the application to ask for the user to save the changes made when he exits without saving. I tried:
GetDocument()->SetModifiedFlag(true);
With this the string displayed in the message box becomes:
"Save changes to untitled?" I need to make this "Do you wish to save changes made to configuration?"
2. Change the application name that appears in all the message boxes (in the title bar). How do I do that? Currently all of them show "xyzProject" and I need "XYZ Application"
Thanks in advance!
|
|
|
|
|
help_wanted wrote:
I need to make this "Do you wish to save changes made to configuration?"
You'll need to provide your own SaveModified() method.
help_wanted wrote:
2. Change the application name that appears in all the message boxes (in the title bar). How do I do that?
This comes from the app's m_pszAppName member variable.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks a lot! This was awesome. I appreciate the assistance you have provided me and the time you've spent answering questions from a beginner like me.
Are there any books that go into more detail about the communication model etc here? I see a lot of books with stuff on how to get started and build your first appln, but nothing more detailed.
|
|
|
|
|
Hai,
I'm new to vc++ win32...i am trying to read and write to serial port COM1.
I know we can do this by createfile and read and writefile fns..but i am not sure about the flags and how to set buffer values..and what other funcs i need to do..suppose i want to write say "hello" to com1 and get the acknowledge "hi" from it...can any one help me with the code exactly how to do it..
thanks a lot.
|
|
|
|
|
You can use
The DCB structure defines the control setting for a serial communications device.
after this you can comunicate as you sain with createfile and writefile..
Murali.
|
|
|
|
|
Hai,
I have created a file using createfile function. but when i executed it, it gives ERROR_ACCESS_DENIED error in Getlasterror function.
How should i overcome this.what shoulg i set the security attribute value.
thanks.
|
|
|
|
|
Make sure you close the file before you try to execute it.. Just a guess.
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Specify the file access flag as CFile::modeWrite in CreateFile Function.
I hop this will work.
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
I have some souce cod please look into, this will append at the end of the file.
void WriteOutputDebug(char* tempStr, int length)
{
HANDLE hfile;
DWORD word;
char tempBuf[20] = "C:\\OutputDebug.txt";
hfile = CreateFile(tempBuf, GENERIC_WRITE | GENERIC_READ, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
SetFilePointer(hfile, 0, NULL, FILE_END);
WriteFile(hfile, tempStr, length, &word, 0);
CloseHandle(hfile);
}
Murali.
|
|
|
|
|
Hello,
I am trying to pass data through a CSocket using CSocketFile and CArchive.. Everything works great except if the network connection breaks it thows a CFileException when sending.. I am trying to handle the exception with the following code..
2 problems:
1st) is when I exit the app i get a memory leak, I am guessing that it's because the ar_send.Flush() is what is throwing the exception so the archive data doesn't get flushed..
2nd) the exception throws up a MessageBox and I don't want that, I want to handle the error on my own.. Here is what I have...
CSocketFile sf(&m_sSocket);
CArchive ar_send(&sf, CArchive::store);
TRY {
ar_send << strSend;
ar_send.Flush();
ar_send.Close();
sf.Close();
}
CATCH_ALL(error){
TCHAR szCause[4096];
error->GetErrorMessage(szCause,4096,NULL);
TRACE("OnSend() Error: %s\n",szCause);
} END_CATCH_ALL;
Thanks!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I found a article on another site that talked about my problem.. here is a little blurb from the article...
If the terminating socket has been closed, calling Flush on the CArchive will raise an exception (so will calling Close). In the previous case, before the exception is handled, CArchive goes out of scope and its destructor calls Close. Close throws another exception and all hell breaks loose. Never throw exceptions from destructors.
You will need nested try / catch blocks ... [Article^]
My problem with the exceptions is fixed but I still have a memory leak.. Any ideas??
void CMainFrame::OnSend(CClientSocket *pSocket, CString strMsg)
{
if(*pSocket != INVALID_SOCKET)
{
try
{
sendObject(pSocket, strMsg);
}
catch (CException* pEx)
{
pEx->Delete();
}
}
}
BOOL CMainFrame::sendObject(CClientSocket *pSocket, CString strMsg)
{
BOOL bRet = TRUE;
CSocketFile sf(pSocket);
CArchive ar_send(&sf, CArchive::store);
try
{
ar_send << strMsg;
ar_send.Flush();
ar_send.Close();
sf.Close();
}
catch (CException* pEx)
{
bRet = FALSE;
pEx->Delete();
}
return bRet;
}
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
i'm tryin to do this program and i don't know how to go about doing it. i tried it one way but it didn't work.
The goal of the program is to encode input messages using the following encryption strategy:
The message sender iputs a four letter word , CCCC, and another for letter word XXXX. The message sender then inputs the message to be sent. The program scans the message one character at a time and each character is pushed in the stack until either the scanned character is in the word CCCC or the end of message is encountered. When the scanned characters in CCCC, print that charcater until the stack is empty or the chracter at the top is one of the chracters XXXX. Whne the end of the message is encountered, print the chracter at the top of the stack and continue to pop and print the stack top until the stack is empty.
for example:
word 1 = GOOD
word 2 = LUCK
message to be encoded = SOUNDS SIMPLE TO ME
encoded message = OSDNOT EEM LPMIS SU
this is what i have so far:
#include <cctype>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
class stack
{
private:
char stacks[50];
int top;
public:
void push(char);
char pop(char &);
bool empty();
bool full();
stack()
{
top=0;
}
};
bool stack::empty()
{
if (top==0)
return true;
else
return false;
}
bool stack::full()
{
if (top==50)
return true;
else
return false;
}
void stack::push(char x)
{
if (full())
exit(1);
else
top++;
stacks[top]=x;
}
char stack::pop(char &x)
{
if (empty())
exit(1);
else
x=stacks[top];
top--;
return (x);
}
int main()
{
stack s1;
char word1[5];
char word2[5];
char message[50];
int len;
char catchvar;
cout<<"Enter Encryption word 1 : ";
cin.getline(word1,5);
cout<<"Enter Encryption word 2 : ";
cin.getline(word2,5);
cout<<"Enter message to be encypted : ";
cin.getline(message,50);
len=strlen(message);
cout<< "Encypted message is : ";
for (int i=0; i<5; i++)
{
for(int j=0; j
|
|
|
|
|
whats with the © copyright notice?
is this your code?
"there is no spoon" biz stuff about me
|
|
|
|
|
|
I found in several examples the function _mbstowcsz, but I don't find anywhere it's explanation.
Does anyone know exactly why on a certain place this will be used instead of mbstowcs?
|
|
|
|
|
i would imagine (guessing here) that the z on the end indicates it would be used with a zero terminated string?
"there is no spoon" biz stuff about me
|
|
|
|
|
The mbstowcs function does convert a NULL of the source string and stops there.
It IS possible, that mbstowcsz appends a zero even if it has not found any in the source string.
My point is, that this function is not documented even in the online MSDN (it appears only in two examples), and people are following this blindly.
Do you use a function, because you BELIEVE that it will work a certain way? (It is a rhetorical question.)
|
|
|
|
|
_mbstowcsz is defined in AtlMisc.h in WTL, also in CStringT.h in MFC7.
In both cases the function calls ::MultiByteToWideChar() and then sets the last character in the string to a NULL.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Thanx.
_mbstowcsz is defined in AFX.H of VC6, but a definition is not a documentation (there is nothing about it in Visual Studio 6).
I am a bit upset by the lemmings, who are coding and copying code without having an idea of the implications.
|
|
|
|