Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all 3029 articles
Browse latest View live

[RESOLVED] Change item height in CListBox / CListCtrl

$
0
0
Hello,

I need a ownerdraw CListBox where I can change the item height during working with the list.
The msdn says that I can specify the height in OnMeasureItem when the listbox will be created (ownerdrawfixed) or when an item will be inserted (ownerdrawvariable).

Any ideas how to change the height e.g. when I click a button?

I made also some tests with CListCtrl. There I can change the height.
But there is only one height for all items.
Any ideas how to set individual heights for the items?

thx
Ralf

[RESOLVED] MSChart Control

$
0
0
Hi,
Code:

SAFEARRAYBOUND sab[2];

sab[0].cElements =noOfRows; // 59

Using the above code i will fix the row [that is row starting from 0, 1, 2, .. ,59 ].

How can i fix column upto 6000 in MSChart control [column starting from 0, 1000, 2000, ...,6000.]

How Do I Still Use Document/View Architecture for This Application?

$
0
0
Hello,

I am learning to use MFC to code a small project to read and display csv files. I can't use CArchive to correctly read line by line of a text file as pointed out in this post: http://connect.microsoft.com/VisualS...s-chinese-text . So I decided to use CStdioFile as described here http://forums.codeguru.com/showthrea...e-line-by-line . So this means that I can't use Serialize() function of the document class and I need to handle ID_FILE_OPEN message other than CWinApp::OnFileOpen. So where shall I handle ID_FILE_OPEN message now and how can I still comply with the Document/View Architecture?

Thanks,
Brian

How to read images in GDI or GDI+

$
0
0
I am working on application to work with images. I need advise how to open/read images, whether it is jpeg, png, bmp or tiff and get it to bitmap. Is there some universal command for this or I will need more commands, every time testing the extension or format and then to use different method to read the image? Best would be to do it automatically, but I don't know such command.

A custom pyramid-drawing program

$
0
0
Write your question here.
Okay, so I am trying to figure out how to create a program that will draw a triangle using *'s with a base the has a user-inputted number of *'s like so:

*
***
*****
It needs to take a user inputted number and draw a pyramid like the above pyramid with the number of *'s in the base matching the user inputted number (i.e., user enters 10, so the triangle has 10 *'s in the base). I figured it would be best to first create a loop to draw out the correct number of *'s before trying to create another loop to draw out the correct number of spaces, to properly align the *'s into a triangle shape. Any pointers, or help, or explanation would be so helpful. Thanks.

int width = 0;
int height = 0;
int i = 0;
int leafWidth = 0;
int i2 = 1;
int i3 = 1;
int i4 = 1;

cout << "Enter trunk height: " << endl;
cin >> height;
cout << "Enter trunk width: " << endl;
cin >> width;
cout << "Enter leaves width: " << endl;
cin >> leafWidth;
cout << endl;
i2=1;
i3=1;
i4=1;
while (i2<=leafWidth){
while (i3 <=i4){
cout << "*";
i3=i3+1;
i4=i4+2;
}
cout << endl;

i2 = i2+2;
}

Homework Help

$
0
0
Hello, I was working on my C++ homework and was wondering if anyone could help me with part of it. I wrote the .cpp and .h files but now I am stuck. Here is what I am supposed to do:

1. Write a subprogram (not a method) void promptForMovie(Movie & myMovie); that prompts the user for movie information, and returns a Movie object to the calling program. When this command is executed, the user will be asked to supply the attributes for the movie.
2. Write a method void output(ostream & out); that will display movie information as follows:
Movie:
Director:
Year:
Rating:
IMDB URL:

Here is my header file: MovieClass.h

// This is the header file that includes the interface of the Movie class

Code:

#ifndef _MOVIE_
#define _MOVIE_

#include <string>

using namespace std;

        enum Movie_Rating {G,PG,PG13,R,NC17,NR} ;

        class Movie
        {
          public: // interface of the Socialite_user class
                         
                //------------ Constructors ------------------
                       
                        Movie();
                        Movie(const string& title) ;
                        Movie(const string& title,
                              const string& director,
                              Movie_Rating rating,
                              unsigned int year,
                              const string& path) ;
                         
                // ------------------------------------------------------
                // ----- Destructor -------------------------------------
                // ------------------------------------------------------
               
                //        ~Movie();  // To be implemented in a future assignment.
                 
                //------------ Inspectors --------------------
                 
                        string getTitle() const ;
                        string getDirector() const ;
                        Movie_Rating getRating() const ;
                        unsigned int getYear() const ;
                        string getURL() const ;
                 
                //------------ Mutators ---------------------

                        void setTitle(const string& title);
                        void setDirector(const string& director) ;
                        void setRating(Movie_Rating rating)  ;
                        void setYear(unsigned int year)  ;
                        void setURL(const string& path)  ;

                private: // private data fields associated with Socialite_user objects
                        // Underscores indicate a private member variable

                        string title_ ;
                        string director_ ;
                        Movie_Rating rating_ ;
                        unsigned int year_ ;
                        string  url_ ;
        };

#endif

MovieClass.cpp :

// This is the file that includes the implementation of the Movie class

Code:

#include "MovieClass.h"
#include <string>
#include <cstdlib>
#include <ciso646>
#include <sstream>

using namespace std;


//-----------Constructors-----------------

Movie::Movie()
{
                title_ = "";
                director_ = "";
                url_ = "";
                rating_;
                year_;
}

Movie::Movie(const string& title)
{
        title_ = "";
}

Movie::Movie(const string& title, const string& director, Movie_Rating rating, unsigned int year, const string& path)
{
                title_ = "";
                director_ = "";
                url_ = "";
                rating_;
                year_;
}


//---------------Inspectors--------------------------

string Movie::getTitle() const
{
        return title_;
}

string Movie::getDirector() const
{
        return director_;
}

Movie_Rating Movie::getRating() const
{
        return rating_;
}

unsigned int Movie::getYear() const
{
        return year_;
}

string Movie::getURL() const
{
        return url_;
}

//--------------------Mutators-------------------

void Movie::setDirector(const string& director)
{
        director_ = director;
}

void Movie::setRating(Movie_Rating rating)
{
        rating_ = rating;
}

void Movie::setYear(unsigned int year)
{
        year_ = year;
}

void Movie::setURL(const string& path)
{
        url_ = path;
}

And this is supposed to be my test file; I am pretty sure I wrote this completely wrong. I think this is where I would put the subprogram and method they are asking for?: main.cpp

Code:

// This is the file that will test the implementation of the MovieClass

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include "MovieClass.h"

using namespace std;

//------------------------------------------------------
//        Prints out Movie Information
//------------------------------------------------------

        void output(ostream & out);

int main(void)
{
        Movie promptForMovie;

        cout << "Movie: " << Movie.setTitle << endl;
        cout << "Director: " << Movie.setDirector << endl;
        cout << "Year: " << Movie.setYear << endl;
        cout << "Rating: " << Movie.setRating << endl;
        cout << "IMDB URL: " << Movie.setURL << endl;
       
        ofstream myfile;
    myfile.open ("MovieTest.txt");

    myfile << "Movie: ";
    myfile << promptForMovie.getTitle();
    myfile << "\n";
        myfile << "Director: ";
        myfile << promptForMovie.getDirector();
        myfile << "\n";
        myfile << "Year: ";
        myfile << promptForMovie.getYear();
        myfile << "\n";
        myfile << "Rating: ";
        myfile << promptForMovie.getRating();
        myfile << "\n";
        myfile << "IMDB Url: ";
        myfile << promptForMovie.getURL();
        myfile << "\n";

    myfile.close();
    return 0;
}

Edit & Run


Thank you

Abut the push/pull of modeling like SketchUp

$
0
0
See the push/pull of modeling in SketchUp, it is very convenient, I would like to achieve in my own programs, Is it possible?

Already defined function error LNK2005

$
0
0
I created a very simple c++ win32 project in MSVC 2010.

I added a .cpp file with the function definition and a .h file with the function prototype and I get this "function already defined" error.

I included both .h and .cpp file to the corresponding stdafx.h and stdafx.cpp files.
I really dont see what can be the problem. I did exactly as on the video tutorial where it was working.

Player.cpp
Code:

#include "stdafx.h"

void f()
{
    MessageBox(0,0,0,0);
}

Player.h
Code:

void f();
Quote:

1>stdafx.obj : error LNK2005: "void __cdecl f(void)" (?f@@YAXXZ) already defined in Player.obj
1>D:\DIRECTSHOW\MediaPlayer\Debug\MediaPlayer.exe : fatal error LNK1169: one or more multiply defined symbols found

First Chance Exception CString

$
0
0
Why would the following line of code cause an exception and how can I fix it? This is with Visual Studio 2013 and it is set to use "Multibyte Character Set".
This is a very old program that I was updating.

Code:

thepath = dadir + "\\*.csv";
Both dadir and thepath are type CString.

Prior to this line dadir looks fine when I look at it in the debugger but when I reach this line of code I get


First-chance exception at 0x0FA08EE1 (mfc120d.dll) in GAQUtilities2014.exe: 0xC0000005: Access violation reading location 0xFEFEFFC6.

Unresolved Externals after using #define DLL extern "C" __declspec(dllexport)

$
0
0
In the calling program, I've got
Code:

Error        1        error LNK2019: unresolved external symbol "public: virtual __thiscall Process::~Process(void)" (??1Process@@UAE@XZ) referenced in function __unwindfunclet$??0Arrivals@@QAE@N@Z$0        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        2        error LNK2019: unresolved external symbol "public: __thiscall ExponentialStream::ExponentialStream(double,int,long,long)" (??0ExponentialStream@@QAE@NHJJ@Z) referenced in function "public: __thiscall Arrivals::Arrivals(double)" (??0Arrivals@@QAE@N@Z)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        3        error LNK2019: unresolved external symbol "protected: __thiscall Process::Process(void)" (??0Process@@IAE@XZ) referenced in function "public: __thiscall Arrivals::Arrivals(double)" (??0Arrivals@@QAE@N@Z)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        4        error LNK2001: unresolved external symbol "public: virtual void __thiscall Process::Suspend(void)" (?Suspend@Process@@UAEXXZ)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        5        error LNK2001: unresolved external symbol "public: virtual void __thiscall Process::Resume(void)" (?Resume@Process@@UAEXXZ)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        6        error LNK2001: unresolved external symbol "public: virtual long __thiscall Thread::Current_Thread(void)const " (?Current_Thread@Thread@@UBEJXZ)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        7        error LNK2001: unresolved external symbol "public: virtual long __thiscall Thread::Identity(void)const " (?Identity@Thread@@UBEJXZ)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        8        error LNK2001: unresolved external symbol "public: virtual class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall Thread::print(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (?print@Thread@@UBEAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV23@@Z)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        9        error LNK2001: unresolved external symbol "protected: virtual void __thiscall Thread::terminateThread(void)" (?terminateThread@Thread@@MAEXXZ)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        10        error LNK2001: unresolved external symbol "public: virtual void __thiscall Process::terminate(void)" (?terminate@Process@@UAEXXZ)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        11        error LNK2001: unresolved external symbol "public: virtual void __thiscall Process::reset(void)" (?reset@Process@@UAEXXZ)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        12        error LNK2019: unresolved external symbol "public: static void __cdecl Resource::operator delete(void *)" (??3Resource@@SAXPAX@Z) referenced in function "public: virtual void * __thiscall Arrivals::`scalar deleting destructor'(unsigned int)" (??_GArrivals@@UAEPAXI@Z)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        13        error LNK2019: unresolved external symbol "protected: void __thiscall Process::Hold(double)" (?Hold@Process@@IAEXN@Z) referenced in function "public: virtual void __thiscall Arrivals::Body(void)" (?Body@Arrivals@@UAEXXZ)        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\Arrivals.obj        PerfectSim
Error        14        error LNK1120: 13 unresolved externals        E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\bin\Debug\\PerfectSim.exe        PerfectSim

Are protected members of this class not allowed to be accessed outside the DLL?
I've packed the file named process.cc and process.h into a simudll.lib and a simudll.dll file
I've made one copy of the header files at the perfectsim project. I've changed that to dllimport to no avail
Thanks
Jack

Code:


#define DLL extern "C" __declspec(dllexport)

DLL class Process : public Thread
{
    friend Scheduler;

public:
    static const double Never;

    virtual ~Process ();
   
    /* The following two methods return the current simulation time */

    static double CurrentTime ();      // C++SIM version
    double Time () const;                // SIMULA version

    double evtime () const;  // time at which process is scheduled to be active

    /*
    * The following method returns a reference to the next process to be run
    * by the scheduler *if* this object is active or scheduled to run.
    */

    const Process* next_ev () const;

    /*
    * There are five ways to activate a process:
    *  1) at the current simulation time
    *  2) before another process,
    *  3) after another process,
    *  4) at a specified (simulated) time, or
    *  5) after a specified (simulated) delay
    */

    void Activate ();
    void ActivateBefore (Process &);
    void ActivateAfter  (Process &);

#ifndef __GNUG__
    void ActivateAt    (double AtTime = CurrentTime(), Boolean prior = FALSE);
    void ActivateDelay  (double AtTime = CurrentTime(), Boolean prior = FALSE);
#else
    void ActivateAt    (double AtTime = SimulatedTime, Boolean prior = FALSE);
    void ActivateDelay  (double AtTime = SimulatedTime, Boolean prior = FALSE);
#endif

    /*
    * Similarly, there are five ways to reactivate
    * Note that if a process is already scheduled, the reactivate
    * will simply re-schedule the process.
    */

    void ReActivate ();
    void ReActivateBefore (Process &);
    void ReActivateAfter  (Process &);

#ifndef __GNUG__
    void ReActivateAt    (double AtTime = CurrentTime(), Boolean prior = FALSE);
    void ReActivateDelay  (double AtTime = CurrentTime(), Boolean prior = FALSE);
#else
    void ReActivateAt    (double AtTime = SimulatedTime, Boolean prior = FALSE);
    void ReActivateDelay  (double AtTime = SimulatedTime, Boolean prior = FALSE);
#endif

    void    Cancel ();                // cancels next burst of activity, process becomes idle
    Boolean idle () const;        // TRUE if process is not awake or not scheduled to wake up

    Boolean passivated () const; // returns whether or not the object has been passivated
    Boolean terminated () const; // returns whether or not the object has been terminated

    virtual void terminate ();  // terminate the process - no going back!

    static const Process* current ();  // returns current process

    /*
    * The pure virtual function, Body, defines the code that executes in
    * the process.
    */

    virtual void Body () = 0;

    /*
    * This method is called whenever a simulation is reset. Default does
    * nothing.
    */
   
    virtual void reset  ();

    static Process* Current;
   
protected:
    Process ();
    Process (unsigned long stackSize);

    void Hold (double t);    // suspend current process for simulated time t
    void Passivate ();              // suspend current process (i.e., make idle)

    void set_evtime (double); // set wakeuptime (used by Scheduler)

    // remove from scheduler queue and prepare for passivation   
    void unschedule ();

private:
    Boolean schedule ();
    Boolean checkTime (double) const;

    double  wakeuptime;
    Boolean Terminated;
    Boolean Passivated;

public:
    virtual void Suspend ();
    virtual void Resume ();
};

problem floating CDialogbar on multiple screen environment

$
0
0
Hello,

I have an problem with a CDialogbar if my app runs on a system with two screens (side by side).
I can not resize it while the CDialogbar is in floating state on the second screen.
I figured out that the problem is the mfc-function CDockContext::Stretch().
It limits the CDialogbar to the primary screen (using ::GetDesktopWindow() to verify the position).

What can I do?

LNK2001: unresolved external symbol when building for x64 platform

$
0
0
The project builds on Win32 platform, but not on x64.

Full error message: dllentry.obj : error LNK2001: unresolved external symbol "class CFactoryTemplate * g_Templates" (?g_Templates@@3PAVCFactoryTemplate@@A)

The dllentry.cpp (a DirectShow base class) compiles on both platforms. It contains the external declarations:

extern CFactoryTemplate g_Templates[];
extern int g_cTemplates;

g_Templates[] is then used in two functions:

__control_entrypoint(DllExport) STDAPI DllGetClassObject(__in REFCLSID rClsID,
__in REFIID riid, __deref_out void **pv)
{
...
for (int i = 0; i < g_cTemplates; i++)
{
const CFactoryTemplate * pT = &g_Templates[i];
}
}

and

DllInitClasses(BOOL bLoading)
{
...
for (int i = 0; i < g_cTemplates; i++)
{
const CFactoryTemplate * pT = &g_Templates[i];
}
}

myClass.cpp contains the definitions for the two externals in dllentry.cpp, at top level, just after the includes:

CFactoryTemplate* g_Templates=0;
int g_cTemplates=0;

myClass.cpp also compiles by itself, but the project does not build. I checked all the libraries in the project settings and all seems to be OK, the 64 bit versions are used.

What should I do to make the project build for x64 platform?

Loops and Vectors

$
0
0
How would I make a loop that would simultaneously compute both the max and min of a vector?

Why I cannot open tiff file?

$
0
0
I am trying libtiff library (I downloaded the source codes as part of SDL2, but I test it separately). There is a test file named ascii_tag.c.

There is a line
Code:

tif = TIFFOpen(filename, "r");
and it breaks here when I run the program. Filename is:
Code:

static const char filename[] = "images/ascii_test.tiff";
and the file exists on disk, because the program just create it and closed the file handler. The error I got:
Debug assertion failed ... program name ... File: (and this is the strange thing!) f:\dd\vctools\crt_bld\self_x86\crt\src\fstat64.c
line:64

Why it displays this path? I did not added this path to project so why it tries to call this file? I have installed VC in different location and running x86 32bit machine.

I already succeed to run test raw_decode.c where I used libtiff.lib and libjpeg.lib also here I used the libraries. I already succeed to open file there using
Code:

tif = TIFFOpen(srcfile,"r");
and srcfile = "./images/quad-tile.jpg.tiff".

Well I tried to use different path as "./images/ascii_test.tiff" but this also results in break. Where could be the problem that ascii_test.tiff cannot be opened?

Complete code:
Code:

/* $Id: ascii_tag.c,v 1.7 2008/04/15 13:32:12 dron Exp $ */

/* Copyright (c) 2004, Andrey Kiselev  <dron@ak4719.spb.edu>
 * GNU */

/*
 * TIFF Library
 *
 * Module to test ASCII tags read/write functions.
 */

#pragma once
#define _CRT_SECURE_NO_WARNINGS
//#pragma warning( disable : 4355 )
//#pragma warning( disable : 4101 )
#pragma warning( disable : 4099 )

#include "tif_config.h"

#include <stdio.h>
#include <string.h>

#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif

#include "tiffio.h"

static const char filename[] = "./images/ascii_test.tiff";

static const struct {
        ttag_t                tag;
        const char        *value;
} ascii_tags[] = {
        { TIFFTAG_DOCUMENTNAME, "Test TIFF image" },
        { TIFFTAG_IMAGEDESCRIPTION, "Temporary test image" },
        { TIFFTAG_MAKE, "This is not scanned image" },
        { TIFFTAG_MODEL, "No scanner" },
        { TIFFTAG_PAGENAME, "Test page" },
        { TIFFTAG_SOFTWARE, "Libtiff library" },
        { TIFFTAG_DATETIME, "2004:09:10 16:09:00" },
        { TIFFTAG_ARTIST, "Andrey V. Kiselev" },
        { TIFFTAG_HOSTCOMPUTER, "Debian GNU/Linux (Sarge)" },
        { TIFFTAG_TARGETPRINTER, "No printer" },
        { TIFFTAG_COPYRIGHT, "Copyright (c) 2004, Andrey Kiselev" },
        { TIFFTAG_FAXSUBADDRESS, "Fax subaddress" },
        /* DGN tags */
        { TIFFTAG_UNIQUECAMERAMODEL, "No camera" },
        { TIFFTAG_CAMERASERIALNUMBER, "1234567890" }
};
#define NTAGS  (sizeof (ascii_tags) / sizeof (ascii_tags[0]))

static const char ink_names[] = "Red\0Green\0Blue";
const int ink_names_size = 15;

int
main()
{
        TIFF                *tif;
        size_t                i;
        unsigned char        buf[] = { 0, 127, 255 };
        char                *value;

        /* Test whether we can write tags. */
        tif = TIFFOpen(filename, "w");
        if (!tif) {
                fprintf (stderr, "Can't create test TIFF file %s.\n", filename);
                return 1;
        }

        if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 1)) {
                fprintf (stderr, "Can't set ImageWidth tag.\n");
                goto failure;
        }
        if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, 1)) {
                fprintf (stderr, "Can't set ImageLength tag.\n");
                goto failure;
        }
        if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) {
                fprintf (stderr, "Can't set BitsPerSample tag.\n");
                goto failure;
        }
        if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, sizeof(buf))) {
                fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
                goto failure;
        }
        if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) {
                fprintf (stderr, "Can't set PlanarConfiguration tag.\n");
                goto failure;
        }
        if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB)) {
                fprintf (stderr, "Can't set PhotometricInterpretation tag.\n");
                goto failure;
        }

        for (i = 0; i < NTAGS; i++) {
                if (!TIFFSetField(tif, ascii_tags[i].tag,
                                  ascii_tags[i].value)) {
                        fprintf(stderr, "Can't set tag %lu.\n",
                                (unsigned long)ascii_tags[i].tag);
                        goto failure;
                }
        }

        /* InkNames tag has special form, so we handle it separately. */
        if (!TIFFSetField(tif, TIFFTAG_NUMBEROFINKS, 3)) {
                fprintf (stderr, "Can't set tag %d (NUMBEROFINKS).\n",
                        TIFFTAG_NUMBEROFINKS);
                goto failure;
        }
        if (!TIFFSetField(tif, TIFFTAG_INKNAMES, ink_names_size, ink_names)) {
                fprintf (stderr, "Can't set tag %d (INKNAMES).\n",
                        TIFFTAG_INKNAMES);
                goto failure;
        }

        /* Write dummy pixel data. */
        if (!TIFFWriteScanline(tif, buf, 0, 0) < 0) {
                fprintf (stderr, "Can't write image data.\n");
                goto failure;
        }

        TIFFClose(tif);
       
        /* Ok, now test whether we can read written values. */
        tif = TIFFOpen(filename, "r");
        if (!tif) {
                fprintf (stderr, "Can't open test TIFF file %s.\n", filename);
                return 1;
        }

        for (i = 0; i < NTAGS; i++) {
                if (!TIFFGetField(tif, ascii_tags[i].tag, &value)
                    || strcmp(value, ascii_tags[i].value)) {
                        fprintf(stderr, "Can't get tag %lu.\n",
                                (unsigned long)ascii_tags[i].tag);
                        goto failure;
                }
        }

        if (!TIFFGetField(tif, TIFFTAG_INKNAMES, &value)
            || memcmp(value, ink_names, ink_names_size)) {
                fprintf (stderr, "Can't get tag %d (INKNAMES).\n",
                        TIFFTAG_INKNAMES);
                goto failure;
        }

        TIFFClose(tif);
       
        /* All tests passed; delete file and exit with success status. */
        unlink(filename);
        return 0;

failure:
        /*
        * Something goes wrong; close file and return unsuccessful status.
        * Do not remove the file for further manual investigation.
        */
        TIFFClose(tif);
        return 1;
}

/* vim: set ts=8 sts=8 sw=8 noet: */

Button to display text box message

$
0
0
I'm new to GUI programming with windows visual studio 2010.

I'm currently making a math helping program in c++ windows form application.
I'm trying to make it so where the user presses the number button I such as 1 button to display a 1 in my textbox.

Code:



private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                       
                }


problem with library (dll)

$
0
0
Got a third party library that seems (maybe) to be written in a managed language (managed c++). On non windows 7 platform like XP, call backs and other features work except that when I move it to windows 7, the library works with GUI apps like MFC GUI applications. It does not work with the console apps calling the APIs. The same APIs work from the MFC GUI but not from the console apps. The Call backs from the console do not get invoked or it even, in rare, cases it crashes. I have read several same issues but have not found a solution yet.

Draggin and dropping functionality in windows 8 environment

$
0
0
Hi,

i have developed an application in which i have icons in left side pane of application which can be dragged and dropped in client screen. Application is working fine with all the resolution except 1920x1080.

when setting the resolution to 1920x1080 while dragging icons to client area, icon is not attach to mouse pointer. instead there is a gap between the mouse pointer and the icon. i wrote code to identify the screen resolution but it does not seem to recognize 1920x1080 resolution. below code is giving incorrect resolution for 1920x1080 setting.

RECT actualDesktop;
GetClientRect(GetDesktopWindow(),&actualDesktop);

value of 'actualDesktop' variable is {top=0 bottom=783 left=0 right=1536} which is incorrect. according to current resolution size value should be {top=0 bottom=1080 left=0 right=1920}. Due to this, all the icons while dragging are adjusting according to incorrect resolution setting.

Can someone help me to identify the issue and let me know if there is any limitation with respect to screen resolution in VC++ 6.0 with windows 8 environment.

I am getting same issue when compiling in VS2012 in windows 8. Code does not seem to recognize 1920x1080 resolution setting and downgrading my application look and feel by setting it to lower resolution.

Any help would be appreciated. If require i will place more detailed code about the drag and drop functionality.

Regards,
Aniket

Menu item font resizing

$
0
0
Hi,

My application menu items which are created dynamically. When window DPI settings gets changed and set to 'Larger (150%)', menu item text is not visible as it is very big and hiding behind the toolbar.

How can we set menu item font size or complete menu pane itself using VC++ by code so that it will be visible in all the DPI settings?

Regards,
Aniket

Problem with newly installed Visual Studio 2012

$
0
0
I have recently installed Visual Studio 2012. I downloaded and ran this simple program

http://code.msdn.microsoft.com/windo...a140b5#content

But looks like the configuration settings of Visual studio 2012 are bit complicated. I came across these errors.

Although I did googled and made these entries in the configuration settings

Code:

$(WindowsSDK_IncludePath)
$(WindowsSDK_LibraryPath_x64)

But still it didn't resolve the errors. Is there anything additional I need to do. Looks like it does recognize mfc header files but all SDK header files associated with Windows.h and it is unable to find out.

Code:

Error        2        error : Required file "tracker.exe" is missing.        C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets        347
        3        IntelliSense: cannot open source file "Windows.h"        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        8
        4        IntelliSense: cannot open source file "WinHttp.h"        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        9
        5        IntelliSense: identifier "DWORD" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        14
        6        IntelliSense: identifier "ERROR_SUCCESS" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        14
        7        IntelliSense: identifier "BOOL" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        15
        8        IntelliSense: identifier "FALSE" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        15
        9        IntelliSense: identifier "HINTERNET" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        16
        10        IntelliSense: identifier "HINTERNET" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        17
        11        IntelliSense: identifier "HINTERNET" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        18
        12        IntelliSense: identifier "HINTERNET" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        19
        13        IntelliSense: identifier "BYTE" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        20
        14        IntelliSense: identifier "BYTE" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        21
        15        IntelliSense: identifier "BYTE" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        22
        16        IntelliSense: identifier "pbCurrentBufferPointer" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        22
        17        IntelliSense: identifier "DWORD" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        23
        18        IntelliSense: identifier "ARRAYSIZE" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        23
        19        IntelliSense: identifier "DWORD" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        24
        20        IntelliSense: identifier "DWORD" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        25
        21        IntelliSense: identifier "USHORT" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        26
        22        IntelliSense: identifier "WINHTTP_WEB_SOCKET_BUFFER_TYPE" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        27
        23        IntelliSense: identifier "INTERNET_PORT" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        28
        24        IntelliSense: identifier "INTERNET_DEFAULT_HTTP_PORT" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        28
        25        IntelliSense: identifier "WCHAR" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        29
        26        IntelliSense: identifier "WCHAR" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        30
        27        IntelliSense: identifier "WCHAR" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        31
        28        IntelliSense: identifier "DWORD" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        32
        29        IntelliSense: identifier "WCHAR" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        32
        30        IntelliSense: identifier "WinHttpOpen" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        38
        31        IntelliSense: identifier "WINHTTP_ACCESS_TYPE_DEFAULT_PROXY" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        39
        32        IntelliSense: identifier "GetLastError" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        45
        33        IntelliSense: identifier "WinHttpConnect" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        49
        34        IntelliSense: identifier "GetLastError" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        55
        35        IntelliSense: identifier "WinHttpOpenRequest" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        59
        36        IntelliSense: identifier "GetLastError" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        68
        37        IntelliSense: identifier "WinHttpSetOption" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        76
        38        IntelliSense: identifier "WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        77
        39        IntelliSense: identifier "GetLastError" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        82
        40        IntelliSense: identifier "WinHttpSendRequest" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        91
        41        IntelliSense: identifier "WINHTTP_NO_ADDITIONAL_HEADERS" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        92
        42        IntelliSense: identifier "GetLastError" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        100
        43        IntelliSense: identifier "WinHttpReceiveResponse" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        104
        44        IntelliSense: identifier "GetLastError" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        107
        45        IntelliSense: identifier "WinHttpWebSocketCompleteUpgrade" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        116
        46        IntelliSense: identifier "GetLastError" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        119
        47        IntelliSense: identifier "WinHttpCloseHandle" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        127
        48        IntelliSense: identifier "WinHttpWebSocketSend" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        136
        49        IntelliSense: identifier "WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        137
        50        IntelliSense: identifier "PVOID" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        138
        51        IntelliSense: expected a ')'        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        138
        52        IntelliSense: identifier "ERROR_NOT_ENOUGH_MEMORY" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        151
        53        IntelliSense: identifier "WinHttpWebSocketReceive" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        155
        54        IntelliSense: identifier "WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        172
        55        IntelliSense: identifier "ERROR_INVALID_PARAMETER" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        181
        56        IntelliSense: expected an expression        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        185
        57        IntelliSense: expected a ')'        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        185
        58        IntelliSense: identifier "WinHttpWebSocketClose" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        191
        59        IntelliSense: identifier "WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        192
        60        IntelliSense: identifier "WinHttpWebSocketQueryCloseStatus" is undefined        d:\Maverick\Projects\StrikeForce\Samples\WinHTTP WebSocket sample\C++\WinhttpWebsocket.cpp        204

Newbie needs help

$
0
0
Hi,

First let me say think you in advance to anybody who is willing to take the time to help me out.

I am a VB6 guy from way back but trying to update my programming skills. Rather than tackle vb.net I thought I would try C++. I'm working with Visual C++ 2008.

It's been going pretty well for being only a few days into it but I have run into a difficulty. It's probably a very simple thing for experience programmers but C++ is great divergence from VB6 and I'm a little stuck.

My goal is to output a simple log file. I thought this would work best via a source (cpp) file as opposed to rewriting it for every form. I have created the .h header file and the .cpp file but can't seem to make it work. I've rewritten it 50 times at this point and google searched and dug threw my book but can't seem to figure it out.

I will throw some code out here but I know it's messed up and incomplete so please consider it a starting point.

Here is my CPPLog.cpp source file: (what do I actually need to #include and where and how do I need to innitialize the string?)

#include "stdafx.h"
#include "CPPLog.h"
#include <iostream>
#include <string>
using namespace System::IO;
using namespace System;

String ^ sLog;

void pLogWriter(String ^ sLog){
StreamWriter^ LogFile = gcnew StreamWriter("LogFile.txt");
LogFile->WriteLine(sLog);
LogFile->Close();
}


Here is my CPPLog.h header file: (I get an error saying invalid use of void. I read on some web site you can simply use the keyword string in the declaration but don't know if this is correct.)

#ifndef CPPLOG_H
#define CPPLOG_H

void pLogWriter(string);

#endif


Here is my calling function, or is it method, from main:

#include "CPPLog.h"

pLogWriter("Test");

Thanks again for your help, I greatly appreciate it.
Viewing all 3029 articles
Browse latest View live


Latest Images