荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: tang (独孤九剑), 信区: Program
标  题: MSVC-BEGINNERS Digest - 17 May 1998 to 18
发信站: BBS 荔园晨风站 (Wed May 20 00:54:53 1998), 转信

There are 18 messages totalling 821 lines in this issue.

Topics of the day:

  1. CArchieve Exceptions
  2. How to set the focus? (2)
  3. try-catch
  4. Run batch files (3)
  5. a C++ class doubt... (2)
  6. To Get Drives Icon
  7. Icon & Text in ComboBox (2)
  8. quick question...
  9. User Interface Vs  Worker Thread (2)
 10. UserId in VC++ ?
 11. Re Try-catch
 12. Win32 App  to create a few second pause.
Hi
This snipped peece of code seems to be ok but I guess because  in this
code you do nothing with str
there must be something you did not send.
I guess there is something after the catches that is always executed and
if you got the CFileExcepion
nothing was read and you try to access it.
Refards Norbert

>-----Original Message-----
>From:  O. Chandar Kumar [SMTP:chandar@INFOTECH.STPH.NET]
>Sent:  Saturday, May 16, 1998 5:59 AM
>To:    MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
>Subject:       [MSVC] CArchieve Exceptions
>
>Hi,
>
>Env: win 95, VC 5.0
>
>I am using CArchive object to read the document. Everything is fine, but at
>the end of the reading I am getting two types of exceptions.  one is  End of

>file exceptions. This I am handling without any problem. and the other one i
s
>0x000005 exception. I didn't understand where it is coming from. I tried to
>catch this exception but proved vain. Can any body suggest why this? the
>sample code is as below
>
>
>BOOL CMyDocument::ReadFileContents(CString &sFileName, .....)
>{
>        CFile cfile;
>        BOOL rValue = FALSE;
>        char buf[512];
>        if( !cfile.Open(sFileName,  CFile::modeRead ) )
>                return rValue ;
>
>        CArchive ar( &cfile, CArchive::load, 512, buf );
>
>        BOOL bworking = TRUE;
>        while(bworking)
>        {
>                CString str;
>                try
>                {
>                        bworking = ar.ReadString(str) ;
>                }
>                catch( CException* e )
>                {
>                        // Handle the exception here.
>                        // "e" contains information about the exception.
>                        e->Delete();
>                }
>                catch(...)
>                {
>                        // Handle the all the other type of exceptions if at

>all exists.
>                        // BTW, how to get the execption object when using
>this type of ellipse arguments.
>                        TRACE0("Got other exception");
>                }
>                if(!bworking)
>                        break;
>                .........
>                .........
>                .........
>                .........
>        }
>        ar.Close();
>        cfile.Close();
>
>        return rValue;
>}
>
>Thanx in advance.
GetDlgItem(CEditID)->Enable()

or

GetDlgItem(CEditID)->Disable()
     That's because CException is not the exception thrown by a divide by
     zero.

     Try the following instead:
     try
     {
        int i=0,j;j=5/i;
     }
     catch (CException &e5)
     {
        strcpy(sWhere,"Get\n");
        e5.GetErrorMessage(msg, 511);
        strcat(sWhere,msg);
        AfxMessageBox(sWhere);
        return;
     }
     catch (...)        // i.e. "catch any other exception
     {
           AfxMessageBox("Unknown exception caught");
           return;
     }


        HTH,

                Burkhard




______________________________ Reply Separator _________________________________

Subject: [MSVC] try-catch
Author:  Alex Kleyn <akleyn@HADAX.COM> at Internet
Date:    15/05/98 11:44


Hi,
to catch error in my program i used code
 try
 {
  int i=0,j;j=5/i;
 }
 catch (CException &e5)
 {
  strcpy(sWhere,"Get\n");
  e5.GetErrorMessage(msg, 511);
  strcat(sWhere,msg);
  AfxMessageBox(sWhere);
  return;
 }
but program terminates like i did not use try catch.
Aleks Kleyn.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META content='"MSHTML 4.71.1712.3"' name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT color=#000000 size=2>Hi,</FONT></DIV>
<DIV><FONT color=#000000 size=2>to catch error in my program i used
code</FONT></DIV>
<DIV><FONT color=#000000 size=2>爐ry<BR> {<BR>?
; int i=0,j;j=5/i;<BR>
}<BR> catch (CException &e5)<BR> {<BR>?
strcpy(sWhere,"Get\n");<BR>? e5.GetErrorMessage(msg,
511);<BR>? strcat(sWhere,msg);<BR>? AfxMessageBox(sWhere);
<BR>?
return;<BR> }<BR>but program terminates like i did not use try
catch.</FONT>?</DIV>
<DIV><FONT color=#000000 size=2>Aleks Kleyn.</FONT></DIV>
;</BODY></HTML>
Hello,
    I am writing a program to run seperate batch file on different days of
the week.I want to be able to run seperate files like Monday.bat,Tuesday.bat
etc....
I`ve gotten this far could someone tell me what to do next.
Thanks in advance.
******************************************
#include <iostream.h>
#include <time.h>

void main()
{
     time_t ltime;
     struct tm *today;
time( <ime );
    _tzset();
    today = localtime( <ime );

switch(today->tm_wday){
case 0:
  cout << "Today is Sunday\n";
  break;
case 1:
  cout << "Today is Monday\n";
  break;
case 2:
  cout << "Today is Tuesday\n";
  break;
case 3:
  cout << "Today is Wednesday\n";
  break;
case 4:
  cout << "Today is Thursday\n";
  break;
case 5:
  cout << "Today is Friday\n";
  break;
case 6:
  cout << "Today is Saturday\n";
  break;

default:
  cout << "Error in retreiving day\nprogram halted\n";
  break;
}
}
******************************************************
Hi, I have a doubt about C++ programming, i think the best way to
explain is reporting a example code

    class CMyClass {
        private :
            CMyListClass p;   // problem
        public :
            CMyclass();
            ...
    };

    struct Node {
        CMyClass Element;  // problem
        Node* next;
    };

    class CMyListClass{
        private :
            Node *N;

        public :
            CMyListClass();
            ~CMyListClass();
            void Insert(nuevo * CMyClass);
    }

the compiler report my an error when a create a CMyListClass object
inside CMyClass; can i do this, and if i can, how i can?
in <process.h> or <stdlib.h>
there is the prototype of the function "system"

int system( const char *command )

to run a batch named "pippo.bat" located in "c:\batfiles"
system("c:\batfiles\pippo.bat"

I hope it can be useful

Bye
           Telemaco
Remember for a \ in a c/c++ string you have to type \\

>-----Original Message-----
>From:  Telemaco Sestini [SMTP:tsestini@AISMI.AIS.IT]
>Sent:  Monday, May 18, 1998 2:14 PM
>To:    MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
>Subject:       Re: [MSVC] Run batch files
>
>in <process.h> or <stdlib.h>
>there is the prototype of the function "system"
>
>int system( const char *command )
>
>to run a batch named "pippo.bat" located in "c:\batfiles"
>system("c:\batfiles\pippo.bat"
>
>I hope it can be useful
>
>Bye
>           Telemaco
The compiler has to know the size of CMyListClass to allocate the space
for it but
if he parses the CMyClass he knows nothing about CMyListClass
that is the reason for both problems Try it as follows:

        class Node; // forward declaration
        class CMyClass; // forward declaration

    class CMyListClass{
        private :
            Node *N;

        public :
            CMyListClass();
            ~CMyListClass();
            void Insert(nuevo * CMyClass);
    }

    class CMyClass {
        private :
            CMyListClass p;   // now no problem
        public :
            CMyclass();
            ...
    };

    class Node {
        CMyClass Element;  // now no problem
        Node* next;
    };


>-----Original Message-----
>From:  Manuel Marin [SMTP:mmarin@TELEBASE.ES]
>Sent:  Monday, May 18, 1998 2:08 PM
>To:    MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
>Subject:       [MSVC] a C++ class doubt...
>
>Hi, I have a doubt about C++ programming, i think the best way to
>explain is reporting a example code
>
>    class CMyClass {
>        private :
>            CMyListClass p;   // problem
>        public :
>            CMyclass();
>            ...
>    };
>
>    struct Node {
>        CMyClass Element;  // problem
>        Node* next;
>    };
>
>    class CMyListClass{
>        private :
>            Node *N;
>
>        public :
>            CMyListClass();
>            ~CMyListClass();
>            void Insert(nuevo * CMyClass);
>    }
>
>the compiler report my an error when a create a CMyListClass object
>inside CMyClass; can i do this, and if i can, how i can?
At 06:25 PM 5/15/98 -0700, you wrote:
>Hi All,
>
>   I have 3 radio buttons and corresponding 3 edit  boxes.
>
>Q:
>    When the user checks a radio button,
>     How can I set the focus( cursor) to the corresponding Edit box,
>     and disable the other two edit boxes?
>
>Thanks,
>//Ramki

Ramki,

One simple way would be to add an event handler for your three radio
buttons on
BN_CLICKED msg.  Using a control member variable for your edit boxes make the
following calls with in each fn:

void CYourDlg::OnRadio1()
{
        m_eOne.SetReadOnly(TRUE);
        m_eTwo.SetReadOnly(FALSE);
        m_eThree.SetReadOInly(FALSE);

        ...bla...bla...bla...
}

Garth
Gurus,

I am simulating Explorer, for our
project. But I am not able to
retrieve Drives Icon.

How can I retrieve the Icon
for the Respective Drive.

Any suggestions are welcome.

Cheers,
Shanmuganathan.S





_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
Gurus,

How to add Both Icon & Text
in ComboBox.

There are examples to add
**only bitmaps** to
ComboBox, but not both
Icon & Textin ComboBox.

Something like ListControl or
TreeControl with Icon & Text,
I want same in ComboBox.

Any WebSites, Examples or
Suggestions are welcome.

Cheers,
Shanmuganathan.S





_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
Bill, what you're saying makes complete sense to me, but the file that I
have has already been created in the aforementioned format. *pauses a
moment* I s'pose I could use a find and replace to make the yy a yyyy. I've
been reading and I'm wondering if the Coblist (or something like that)
would be appropriate. I've noticed that there are a few to choose from, one
for pointers, one for obejects and one other I don't remember from the top
of my head. Since I wish my node to contain nine data elements, should I
use the object list?

Franklyn

-----Original Message-----
From:   Cavanaugh, Bill [SMTP:Bill.Cavanaugh@FMR.COM]
Sent:   Sunday, May 17, 1998 9:34 AM
To:     MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
Subject:        Re: [MSVC] quick question...

Ok, first, mm/dd/yy is WRONG! WRONG! It's 1998! USE A FOUR-DIGIT YEAR!!!!

Ah, now that I've gotten that out of my system (I'm on a contract doing Y2K
assurance, so I get to see that kind of thing all day...)

Read up on archives. Read about CString and CDate. Look at CStdioFile.
Check
out the CArray template classes.

Bill

On Saturday, May 16, 1998 4:27 PM, Franklyn Colebrooke, Jr.
[SMTP:colebrookef@POST.UWSTOUT.EDU] wrote:
> MSVC 5. Win95.
>
> Ok, summer is here and I'm finally taking the time to use MSVC as it
> should
> be used. The question I have to ask is something I can do by creating
> my
> own files and the like and continuing from there, but this time I
> choose to
> use the MFC wizard. I've created a MDI and now wish to add some code
> to it.
> I have a file that has its contents in this format:
>
> Day, mm/dd/yy      00      00      00      00      00      00
>             $000,000,000
>
> (the spacing is not exact)
>
> now what I would like to do (well, step one) is to open the file, read
> in
> the data, store it into a node, and then display the contents. I
> choose the
> linked list option because the size of this list will vary. Could
> someone
> guide me in the right direction as to how I might accomplish this
> through
> use of the class wizard or whatever else would be appropriate?
>
> *side note- I don't wish to make the date a string, because I wish to
> perform calculations with it.
>
> Trying to learn-
> Franklyn
Gurus,

Please tell me Difference between
User Interface & Worker Thread.

How to create these threads?

Any Suggestions are welcome.

Bye,
Shanmuganathan.S




_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
At 11:45 AM 5/18/98 -0700, you wrote:
>Gurus,
>
>Please tell me Difference between
>User Interface & Worker Thread.
>
>How to create these threads?
>
>Any Suggestions are welcome.
>
>Bye,
>Shanmuganathan.S

Shanmuganathan,

Far be it that I would clam the guru title but...basically a user interface
thread has its own message handling (loop) abilities and a worker thread
doesn't.  Because of this worker threads are simpler to implement just
declare a global function with a prototype of:

UINT MyWorkerThread( LPVOID pParam );

With in this function will contain the code that performs what you want the
thread to accomplish.
Then when you need to begin the thread call: AfxBeginThread it returns a
pointer to the thread that you can use to resume or suspend it with if
necessary.  Interface threads are more complex the on-line help has several
examples you should look at.

Garth
Thanks Raghu,  It really helped.  For some reason in my system, I
passed "username" instead of LOGNAME.

Thanks,
//Ramki


> -----Original Message-----
> From: S.Vinayak Raghuraman [SMTP:svraghu@RUKSUN.COM]
> Sent: Saturday, May 16, 1998 2:21 AM
> To:   MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
> Subject:      Re: [MSVC] UserId in VC++ ?
>
> From: Natesan, Ramki <RNatesan@BACTC.COM>
>    How can I get UserID in VC++ ?
>
> As far as i know, the user id is the login name of the user.  getting
> which
> is very straight forward.
>
> Try this. (this will work in c, c++, vc++. win95,NT).
>
> char *uid;
> uid = getenv( "LOGNAME" );
> if( uid != NULL )
> TRACE( "User ID is: %s\n",uid );
>
> Hope this helps.
>
> Regards,
>
> Raghu
> Software Engineer,
> Ruksun Software Technologies,
> svraghu@ruksun.com
>
> ~~~~~~~~~~~~~~~~~~~
> Dreams and Dedication make a powerful Combination.
> ~~~~~~~~~~~~~~~~~~~
Hi Burkhard
How I understand from your email I cannot write common catch operator to analize
 error but separate for few groups and analize each group separately.
Thank you, Aleks Kleyn
I did this some time back for a listbox (combobox should be same), but don't
have code handy.  Basically, you need to make it an Owner-draw and override
the DrawItem virtual function.  You then use DrawIcon, and DrawText (see the
documentation)



> -----Original Message-----
> From: owner-msvc-beginners@MAELSTROM.STJOHNS.EDU
> [mailto:owner-msvc-beginners@MAELSTROM.STJOHNS.EDU]On Behalf Of
> Shanmuganathan Sankaranainar
> Sent: Monday, May 18, 1998 11:37 AM
> To: MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
> Subject: Icon & Text in ComboBox
>
>
> Gurus,
>
> How to add Both Icon & Text
> in ComboBox.
>
> There are examples to add
> **only bitmaps** to
> ComboBox, but not both
> Icon & Textin ComboBox.
>
> Something like ListControl or
> TreeControl with Icon & Text,
> I want same in ComboBox.
>
What headers files do I need to include to get this to compile?

   main( int argc, char *argv[ ], char *envp[ ] )
   {
       sleep(argv[1*1000]);
       return(0);
   }


I created a minimal workspace by using
  New | Project | Win32 Application

I want a minimal Windows application that exists for a specified
number of seconds, then terminates.  I don't want it to display any
windows.  It will be called by a another Windows application (that I
didn't write and don't have the source code for), which would wait for
it to finish.  The delay is needed for me to work around a bug in this
other program.
--
        There are these few times I feel lonely for you.
        But I know this shade of blue will soon pass through!
        I must be strong without you by my side!
        I can see forever you are my light.

※ 来源:.BBS 荔园晨风站 bbs.szu.edu.cn.[FROM: 192.168.0.4]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店