Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

Philip Nicoletti

@Philip Nicoletti
About
Posts
23
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • storing a windows postion in the registry...
    P Philip Nicoletti

    to save the Window position :

    WINDOWPLACEMENT pwp;
    BOOL            ret;
    
    ret = GetWindowPlacement(&pwp);
    
    
    CString strBuffer;
    
    strBuffer.Format("%i %i %i %i %i %i %i %i %i %i",
    	pwp.flags, pwp.showCmd,
    	pwp.ptMinPosition.x , pwp.ptMinPosition.y , 
    	pwp.ptMaxPosition.x , pwp.ptMaxPosition.y , 
    	pwp.rcNormalPosition.left , pwp.rcNormalPosition.top , 
    	pwp.rcNormalPosition.right , pwp.rcNormalPosition.bottom);
    
    
    AfxGetApp()->WriteProfileString("Settings","windowPos",strBuffer);
    

    to restore the window position :

    WINDOWPLACEMENT pwp;
    CString strBuffer = AfxGetApp ()->GetProfileString("Settings","windowPos");
    
    int cRead = \_stscanf(strBuffer,"%i %i %i %i %i %i %i %i %i %i",
    	&pwp.flags,&pwp.showCmd,
    	&pwp.ptMinPosition.x , &pwp.ptMinPosition.y , 
    	&pwp.ptMaxPosition.x , &pwp.ptMaxPosition.y ,
    	&pwp.rcNormalPosition.left , &pwp.rcNormalPosition.top ,
    	&pwp.rcNormalPosition.right , &pwp.rcNormalPosition.bottom);
    
    if (cRead == 10) SetWindowPlacement(&pwp);
    
    C / C++ / MFC windows-admin question

  • 2 dimensional dynamic arrays
    P Philip Nicoletti

    int nRows = 6; int nCols = 3; int ** cp; // Allocate rows cp = new int *[ nRows ]; // Now allocate using a loop for ( int index = 0; index < nRows; index++ ) { cp[index] = new int [ nCols ]; } cp[5][0] = 1; cp[5][1] = 2;

    C / C++ / MFC data-structures question

  • *** Declaring Array size from User Input ***
    P Philip Nicoletti

    int theUserInput; theUserInput = 10; // or from user input int *array; array = new int[theUserInput]; array[0] = 5; // whatever

    C / C++ / MFC question data-structures help

  • I'm new and i need help with html and all
    P Philip Nicoletti

    see http://planetwebdesign.com/frames.htm for samples you can also do a internet search for html frames many examples should come up

    C / C++ / MFC html help

  • Modeless dialog
    P Philip Nicoletti

    I suspect that your code : CString msg("Message"); CShowMessage swRem(msg); swRem.Create(IDD_SHOWMESSAGE_DIALOG); swRem.ShowWindow(SW_SHOW); is in some function. Once the function returns, static local variables are automattically destroyed. (in your case , msg and swRem). One thing to try is to make these variable global by putting the lines : CString msg("Message"); CShowMessage swRem(msg); at the top of your CPP file.

    C / C++ / MFC help

  • Cursor Postition
    P Philip Nicoletti

    The following code gets the current mouse position :

    POINT point;
    GetCursorPos(&point);

    // point.x and point.y have the mouse position
    // with respect to the entire screen
    // NOT the application

    The problem is to get this code called whenever the mouse moves. WM_MOUSEMOVE only generates messages when in the application window. The only way I have found to do it is as follows: 1) add a WM_TIMER message to your application 2) code it as follows :

    void YOUR_CLASS::OnTimer(UINT nIDEvent)
    {
    // TODO: Add your message handler code here and/or call default

    CDialog::OnTimer(nIDEvent);

    POINT point;
    GetCursorPos(&point);

    // point.x and point.y have the mouse position
    // with respect to the entire screen
    // not the application

    // do whatever you want with these values

    1. start the timer :

    SetTimer(1,200,NULL); // calls OnTimer() every 200 milliseconds

    C / C++ / MFC help

  • CString search
    P Philip Nicoletti

    I think that you put the CountCharacters() function INSIDE of an existing function. Place it at the end of your CPP file (and remember to declare it at the top of the CPP file or in the .H file)

    C / C++ / MFC question help

  • CString search
    P Philip Nicoletti

    I am having problems formatting the "less than sign" (it thinks it is a start of a html tag). CString testString = "test-1test-2test3.txt"; int numberFound = 0; for (int i=0; i LESS_THAN_SIGN testString.GetLength(); i++) if (testString.GetAt(i) == '-')numberFound++; the GetLength() is a member function of the CString class

    C / C++ / MFC question help

  • CString search
    P Philip Nicoletti

    Maybe just count the number of '-' in the string ...

    CString testString = "test1-test2-test3--.txt";

    int numberFound = 0;

    for (int i=0; i<testString.GetLength(); i++)
    if (testString.GetAt(i) == '-') numberFound++;

    C / C++ / MFC question help

  • OpenGL Fast Redrawing
    P Philip Nicoletti

    A few suggestions : 1) have you tried glReadPixels() / glDrawPixels() ? 2) The accumulation buffer is guaranteed to exist in all openGL implementations ... maybe you can use it somehow ? What "windowing" system are you using ? AUX ? GLUT ? wgl ?

    C / C++ / MFC graphics question game-dev workspace

  • Changing TEXT FILES into Access Tables
    P Philip Nicoletti

    Here is some code to read the files ... I don't know anything about creating the access database though. first in your header file, add the member function :

    void get_field(void); // get the next field in the line
    // puts into variable : field
    // assumes that fields are separated
    // by commas

    add to the top of your .CPP file :

    #include <fstream.h> // for file i/o

    Add the following to the top of your .CPP file (or add as member variables in your .H file) :

    #define MAX_CHAR 80 // maximum number of characters per input line

    char field[MAX_CHAR]; // temporary, current field
    char tmp[MAX_CHAR]; // temporary, the entire line read in
    int start; // temporary, place to start looking for
    // the next field in the line

    #define MAX_FIELDS 20 // maximum number of fields

    int numFields; // actual number of fields

    CString tableName; // table name

    CString fieldName[MAX_FIELDS]; // names of the fields

    int fieldCode[MAX_FIELDS]; // 0 = int 1 = float 2 = CString

    Here is the code to read the first file, and determine the number of fields and the type of each field :

    // first ... read the definition file
    
    ifstream infile;
    infile.open("test1.txt");
    
    numFields = 0;
    
    infile.getline(tmp,MAX\_CHAR);
    start = 0;
    get\_field();
    tableName = field;
    
    
    while (!infile.eof())
    {
    	infile.getline(tmp,MAX\_CHAR);
    	if (infile.eof()) break;
    	start = 0;
    	get\_field();
    	fieldName\[numFields\] = field;
    
    	get\_field();
    	CString fieldType;
    
    	fieldType = field;
    	fieldType.MakeLower();
    	fieldType.TrimLeft();
    	fieldType.TrimRight();
    
    	if (fieldType == "integer") fieldCode\[numFields\] = 0;
    	if (fieldType == "float")   fieldCode\[numFields\] = 1;
    	if (fieldType == "string")  fieldCode\[numFields\] = 2;
    
    	numFields++;
    
    }
    infile.close();
    

    Here is the code to read the second file, and determines the value of each field for each record. Write out to a third file to make sure that everything is correct :

    // next ... read the value file
    // (open an output file to make sure we are reading correctly)
    
    infile.open("test2.txt");
    
    ofstream outfile;
    outfile.open("test3.txt");
    
    int num\_records = 0;
    
    while (!infile.eof())
    {
    
    C / C++ / MFC help

  • FTP Server Sample
    P Philip Nicoletti

    The codeproject seems to have some network examples under "Internet/Network". In particular ... http://www.codeproject.com/internet/ftptransferdlg.asp

    C / C++ / MFC c++ sysadmin help question

  • Basic query regarding arrays/data sets
    P Philip Nicoletti

    forgot 1 thing ... at the top of the CPP you also need to add the line :

    #include <fstream.h> // for file i/o

    C / C++ / MFC database

  • Basic query regarding arrays/data sets
    P Philip Nicoletti

    If I understand your question correctly : 1) you have files with a bunch of integers in them 2) you want to read these integers into an array 3) (possibly) manipulate the integers 4) (possibly) write the integers out to file again One possible solution : At the top of your CPP file :

    #define MAX_RECORDS 1000 // max number of data integers

    int array[MAX_RECORDS]; // the array of data integers

    int numRecords; // actual number of integers
    // in the file

    To bring up a file open dialog and read in the data :

    CFileDialog ifile(TRUE,"txt",NULL,OFN_HIDEREADONLY,
    "text files|*.txt|all files|*.*||");

    int result = ifile.DoModal();

    if (result == IDOK)
    {
    CString info;
    info = ifile.GetPathName();

    ifstream infile;
    infile.open(info);

    numRecords = 0;

    while (!infile.eof())
    {
    if (numRecords == MAX_RECORDS) break;
    infile >> array[numRecords];
    numRecords++;
    }
    if (infile.eof()) numRecords--;

    infile.close();

    }

    to bring up a file save dialog and write the data integers to file :

    CFileDialog ofile(FALSE,"txt",NULL,OFN_OVERWRITEPROMPT,
    "text files|*.txt|all files|*.*||");

    int result = ofile.DoModal();

    if (result == IDOK)
    {

    CString info;
    info = ofile.GetPathName();

    ofstream outfile;
    outfile.open(info);

    for (int i=0; i<numRecords; i++)
    outfile << array[i] << "\n";

    outfile.close();

    }

    C / C++ / MFC database

  • Loading a list from file into a List Box
    P Philip Nicoletti

    I also have struggled with C++ I/O .... but this should do the trick : 1) at the top of your cpp file, add the following lines :

    #include "fstream.h"               // for file i/o
    #define MAX\_CHARS\_PER\_LINE 80      // maximum number of characters
                                       //   per line in your input file
    
    1. create a CONTROL variable for your list box (m_list1 in this example) 3) to read the input file and add to the list box :

      char line[MAX_CHARS_PER_LINE];

      ifstream infile;
      infile.open("list.txt");

      while (!infile.eof())
      {
      infile.getline(line,MAX_CHARS_PER_LINE);
      m_list1.AddString(line);
      }

      infile.close();

    C / C++ / MFC c++ json tutorial

  • anti-aliasing algorithm
    P Philip Nicoletti

    The basic idea is this : 1) you calculate the percent coverage of each pixel when drawing the line. 2) you set the pixel color based on the percent coverage. For example, if drawing a white line RGB(255,255,255) : * if the pixel is 100 % covered, set the pixel color to RGB(255,255,255) * if the pixel is 50 % covered, set the pixel color to RGB(127,127,127) etc. The hard part is step 1. The way to see what coverage means is to take a piece of graph paper - each grid cell represents a pixel. Draw a line from a start pixel to an end pixel. But the line is really a long rectangle, in which 2 of the sides are of unit length. You will see that some pixels are nearly fully covered, others on slightly covered. Unfortunately, the details of calculating these coverage values are complex. Maybe some OLD graphics text book will have more info on how to calculate the values. What graphics package are you using ? I know that both openGL and Direct3D support antialiasing. I have not used Direct3D, but the openGL implementation is very easy to use.

    C / C++ / MFC graphics algorithms question

  • Display .TIF images
    P Philip Nicoletti

    You might look in http://www.libtiff.org There is a link for down-loading tiff library software near the top of this page. Near the bottom is a link "Building the software distribution" . That link has instructions for creating the library on Windows using Visual C++. p.s. I have code to open a bitmap file(BMP) and get the "matrix version" of it. I use the bitmap file as a texture in openGL. Hope this helps.

    C / C++ / MFC c++ help tutorial announcement

  • Scrolling to the bottom+colors
    P Philip Nicoletti

    for question #1 Have you tried the LineScroll() member function ? For example, after UpdateData(FALSE); int nVis = m_edit1c.GetFirstVisibleLine(); int nscroll = m_edit1c.GetLineCount() - nVis; m_edit1c.LineScroll(nscroll); (assuming that you have a control variable, m_edit1c, associated with the Rich edit control)

    C / C++ / MFC question

  • GUI - minimize, maximize and close
    P Philip Nicoletti

    I don't know anything about this, but there is a recent post on code project concerning skins. http://www.codeproject.com/dialog/skinsyse.asp

    C / C++ / MFC question

  • How do I handle modeless dialog events?
    P Philip Nicoletti

    Could you give a little more info on what you are trying to do ? The message handling routines work the same, whether in Modal or Modeless. Are you having problems communicating data between the various modeless dialogs that you have set up ?

    C / C++ / MFC question help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups