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

most simple app for Visual Studio

$
0
0
Windows 10, Visual Studio 2008 and 2012

I want to create a simple app that is nothing more than this:
main()
{
for( int i = 1; i < 10; i++ )
{
GetCursorPos( &position );
Change_Position( &position );
SetCursorPos( &position );
sleep( 1000 );
}
}

The use of Win32 Project brings in hoards of unwanted things. Is there such a thing as a simple Visual Studio project that will meet this concept? Is Win32 Project the simplest that can be created?

Taskbar visibility

$
0
0
Hello,

I have an application (A) which can host a MFC application (B) inside. A creates the B process, finds the window handle of B, calls SetParent to make B a child window and MoveWindow to adjust the position of B so it fits inside.

Application A is run in fullscreen which hides the taskbar. However, application B must not be maximized since it has to be shown inside A's window.

When working in the window that belongs to B (for example clicking on the ribbon application button and then in the view) the taskbar becomes visible. It's only when clicking on the portion of the screen that belongs to A that the taskbar hides again.

I couldn't find which function in the Windows API that triggers the taskbar visibility. For example, it doesn't trigger if a mainframe window is maximized and WS_CAPTION is removed during style modification.

I don't want the taskbar to be shown during the lifetime of A. Can the "fullscreen behaviour" be simulated for a child window that doesn't fill the screen? The "fullscreen behaviour" is apparently not inherited by just calling SetParent.

Any advice would be appreciated!

Event Planner Program

$
0
0
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

//This is an Event Planner Program

/* Computer Science IA Unit 2 */

typedef char Data;// Character information of event to be stored in linked list
typedef int Data2; // integer data to be stored in the linked list




//STRUCTURES IN THE PROGRAM

typedef struct stack1{
stack1*contents;//the event to be stored in the stack
int top;
};
//This is the definition of the structure for the program

typedef struct queue1{
char items[5000];//the number of events to be stored in the queue
int front;
int back;
};
//This is the definition of the queue for the program


typedef struct node1{
Data data;//the events to be stored in the queue
Data2 data2;//the events to be stored in the queue
node1 *nextnode;
};
//This is the definition of the node for the linked list

typedef node1* LinkedList1;
//This is the definition of the ENTIRE linked list




typedef struct customerinfostruct{
char customername[];
char gender;
int amountofpeople;
int amounttobepayed;
char contactinfo;
};
//Structure for the customer info



//PROTOTYPES FOR MENUS

char createeventoption(void);
//This function is designed to prompt the user if they wish to create the event

char structureoption(char eventname[],char eventtype[],char eventstart[], char eventend[], float money, int duration, char topics[]);
//This function is designed to prompt the user to select what data structure to save this event too

char mainmenu(void);
//This function is designed to print the main menu to the screen

char quitmenu(void);
//This function is designed to print the quit menu to the screen


void mainmenuswitch();
//This function implements the switch case option for the main menu

void createeventoptionswitch();
//This function implements the switch case option for the main menu

void structureoption();
//This function implements the structure options




//PROTOTYPES FOR THE PROGRAM FUNCTIONS
int createevent(char eventname[],char eventtype[],char eventstart[], char eventend[], float money, int duration);
//This function is designed to actually create the event

char* gettopics(char topics[]);
//This function is designed to get the activities for the event

int addnamestolist(struct customerinfo);
//This function is designed to add the information to array of structs

void printlistofattendants(struct customerinfo);//file pointer to be added
//This function is designed to print the entire list of customer info


//PROTOTYPES FOR STACK FUNCTIONS

void push(stack1);
//This function is add the event to the stack

void pop(stack1);
//This function removes the events from the stack

int isEmpty(stack1);
//This function checks to see if the stack is empty

int isFull(stack1);
//This function checks if the stack is full


//PROTOTYPES FOR QUEUE FUNCTIONS

void enqueue(Data*queue1,int *front, int*back, Data data, Data2 data2);
//This function adds addsthe events to the queue

void dequeue(int*front, int* back, Data*queue1);
//This function removes an event from the queue

int isEmpty(queue1);
//This function checks to see if the queue is empty

int isFull(queue1);
//This function checks to see if the queue is full

//PROTOTYPES FOR THE LINKED LIST FUNCTIONS

void printNode(node1* node);
//This function prints a single node

void printLinkedList(LinkedList1 head);
//This function prints the entire linked list

node1* addnode(node1* position, Data data, Data2 data2);
//This function adds a new node to the linked list

node1* deletenode(LinkedList1 head, node1*address);
//This function deletes a node from the linked list


int main()
{
createevent();

}

int createevent(char eventname[],char eventtype[],char eventstart[], char eventend[], float money, int duration)
{
char name[100];//name of event
char type[50];//type of event
char start[5];//start of the event
char finish[5];//end of the event
float h=0;// budget for event
int g=0;//duration of event


printf("Enter the event name:");//prompt for user input
gets(name);//assign it to the variable called name
printf("Enter the event type:\n");//prompt for event type
gets(type);//assign it to type
printf("Enter the time the event will start:\n");
gets(start);//assign it to type
printf("Enter the time the event will end:\n");
gets(finish);//store it in a variable finish
printf("Enter the budget for the event:\n");
scanf("%f", &h);// look for the float value "h"
printf("Enter the duration for the event:\n");
scanf("%d hours", &g);//look for the float value h
gettopics(0);

return 0;
}

char* gettopics(char topics[])
{
int i= 200;//number of spaces in the array
char points[50];//The variable to store the points in the array
char pointsarray[i];//The variable to store the points in the array

for(i=0;i=200;i++){
printf("Enter the topics to be discussed");
gets(points);
if(*points=1234)
break;
*pointsarray=*points;
}
}

Please explain the errors or what i'm overlooking please

VS 2015 and standard headers

$
0
0
Hello, I'm first time trying to compile old C sources with VC14 and it seems some standard headers are missing

math.h

It appeared as present yet as in VC12. What is replacement of this? Thanks

Forum application/program programming project (outsource) -- recruiting coders

$
0
0
The project consists of a monitoring program for forums. The primary operations consists of reading (downloading posts,pages,replies, ect.), writing (uploading posts,pages,replies, ect.),
direct interactive reading/writing (chat,Flickr, Facebook, Instagram, Pinterest, SMS,Tweeter,instant message (IM) ing with users (with the help of word file)), and of
coarse logging and analizing logs with the use of different algorythms.The writings (uploads) is the outcome of the just mentioned analysis,depending on the combination of the occurance of words
(more on the in the detailed spec). The log/analisys is based on different aspect of data like the type of forum,location of (forum,proxy,user),type of user,time,type of sub-item
(post,page,poll, ect.),Internet protocol used,social network,Web page layout,data formats,char sets,end user hardware device (terminal,PC,tablet,cell, ),OS (Window,UNIX/LINUX,MAC, ect.)
The program would have to:
- use of multiple proxies (to maximize network bandwidth)
- use of multiple CPU/memory adresse (central and withing certain higher level proxies)
- multi-thread (withing each CPU)
- account for network failliures/downtime and have to be auto-reentrant/restart (auto fixing damaged/incomplete data)
- use multiple Internet protocols high level protocols (FTP,HTTP,IRC, ect.)
- use multiple Internet protocols low level protocols (TCP,UDP,MDCP,IP, ect.) for multiple Internet protocols schemes (unicast,multicast,broadcast)
- use multiple low level Internet Protocol Format (IPv4, IPv6, ect.)
- use multiple Network Traffic Route (amongst main program and proxies,and proxies and forum sites)
- taking into account for network optimisation network profile of proxies/end forums/sites
- type of Internet connection (cable, DSL, fiber optic, satellite, ect.)
- baudrate of Internet connection
- Web server (forum) software
- proxy software
- Web server (forum) OS
- proxy OS
- physical real distance of proxies/en Web sites
- wire distance of proxies/en Web sites
- programming language used
- ISP/country/state/county policies (which are sovern BTW (so you have to comply to laws or at least circomvent them in an undetectable way) the later (right) more strigent)
- react on CPU signals
The program would react to both remotely and locally instigated events. That is for example the arrival of a new email would trigger the logging,analisys (word file) and reply from remote,
while a predefined timely event (today is 24th of December,time to send "Mery Christmas wishes") would be local instigated.
The long term data stage would me use of databases,directories and files on hardware.
Of coarse the program would have to be made with security in mind. (encryption,backup,circonvention, ect.), and be re-entrant when a sub-program halts du to error.
The program would also represent interlink between forum site,that is for exmaple what is forum A relation to forum B.

The exact low level global and general structure of a forum site is given an another spec (forum_spec_low_level). Other operations may include (but not limited to) sorting (by key) from
(a defined range), adjusting (data formats (differing amongst operating System (OS),dates,location, ect..),time (differing amongst timezones),language, measurement units (US/metric),
URL formats),searching,analysing data,reactime to network/computer/CPU events ect,ect.

That said (the above),this is a COMPLEX program that suits for EXPIRIANCED programmers and is VERY CHALLENGING.
The knowlege of programming language,network protocols,databases,Operating Systems (OS),hardware is a MUST.
A further spec (forum_spec_low_level) gives every detail to interested programmers.

scep PKIOperation decode and response encode

$
0
0
Hi There,

I am looking for preferably a C/C++ implementation example what can do SCEP PKIOpration decoding (with ssl library or calling openssl externally) and what then can create the answer to put to a std::string or a char *.

Thanks :)

Prevent screen saver from activating

$
0
0
Windows 10, visual Studio, c++

There are some times when I want to prevent the screen saver for activating when there has been no input from the user. But not all the time.
What is the most simple way I can generate some data in an app and make the computer think someone pecked a key or moved the mouse?

how to dynamically set the CRecordset Fieldtype ?

$
0
0
Hi
the problem i am having is that when i try to get
Code:

short nFields = rs.GetODBCFieldCount();
                        CDBVariant b= new CDBVariant[nFields];
                        for (short index = 0; index < nFields; index++)
                        {
                                rs.GetFieldValue(index, b[index],DEFAULT_FIELD_TYPE);               
                        }

now i want to change the DEFAULT_FIELD_TYPE dynamically
so i fount out that using
CODBCFieldInfo c;
rs.GetODBCFieldInfo(index, c);
SQL_C_CHAR h = c.m_nSQLType; //this is not correct but i need a SQL_C_CHAR to pass in rs.GetFieldValue(,,here);

so how i can dynamically pass the nFieldType becuase if i dont the GetFieldValue get the value in binary which is not correct

the data i am getting is in this form
Quote:

1 jack 23 2015-12-13
2 ryan 23 2015-12-13
3 jhon 23 2015-12-13
so the GetFieldValue (,,nFieldType ) should change but its not changing
i get the first field ok mean i get the 1 correctly but the name is in binary and other 2 values also in binary

nFieldType SQL_C_CHAR table is link below
https://msdn.microsoft.com/en-us/library/5f8k59f9.aspx

if i go manually then
for first row

Code:

CDBVariant id;
CDBVariant name;
CDBVariant age;
CDBVariant date;
 rs.GetFieldValue(short(0), id,      SQL_C_SLONG);
 rs.GetFieldValue(short(1), name, SQL_C_CHAR);
 rs.GetFieldValue(short(2), age,    SQL_C_SLONG);
 rs.GetFieldValue(short(3), date,  SQL_C_TIMESTAMP);

but i want to change rs.GetFieldValue(short(0), id,SQL_C_SLONG); this dynamically

program entry point? no int main () or int winmain () ?

$
0
0
So I'm very new to visual c++ but know c++ in general..I was trying to read and understand the source code of a program I found online...so starting from the main.cpp...but I'm not clear where I should start from since I couldn't find no int main () or int winmain () but there is a maindialogProc (), now I post the souce code, can anyone help with some clear clarifications for a pure noob? thanks...

Code:

#include <windows.h>
#include <commctrl.h>
#include <ole2.h>
#include <shlwapi.h>

#include "defines.h"
#include "resources\resources.h"
#include "main.h"
#include "languages.h"
#include "tools.h"

#include "..\common\mem.h"
#include "..\common\str.h"
#include "..\common\crypt.h"
#include "..\common\fs.h"
#include "..\common\gui.h"
#include "..\common\comlibrary.h"

//Ãëîáàëüíûå ïåðåìåííûå.
HMODULE currentModule;      //Õýíäë òåêóøåãî ìîäóëÿ.
WCHAR homePath[MAX_PATH];    //Äîìàøíÿÿ äèðåêòîðèÿ.
WCHAR settingsFile[MAX_PATH]; //Ôàéë îïöèé.

# if defined SUBSYSTEM_CONSOLE

# else
static HRESULT comResult;    //Çíà÷åíèå îò ComLibrary::_initThread().

//Äàííûå î âêëàäêàõ.
INT_PTR CALLBACK toolInformationProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK toolBuilderProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK toolSettingsProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

typedef struct
{
  HWND hwnd;
  DWORD lngId;
  DWORD resId;
  DLGPROC dlgProc;
}TOOLDATA;

static TOOLDATA toolsList[] =
{
  {NULL, Languages::tool_title_info,    DIALOG_TOOL_INFO,    toolInformationProc},
#if(BO_CLIENT_PLATFORMS > 0)
  {NULL, Languages::tool_title_builder,  DIALOG_TOOL_BUILDER,  toolBuilderProc},
#endif
  {NULL, Languages::tool_title_settings, DIALOG_TOOL_SETTINGS, toolSettingsProc},
};
static BYTE lastTool        = 0xFF;
#define toolsCount (sizeof(toolsList) / sizeof(TOOLDATA))

/*
  Çàãðóçêà âêëàäêè.

  IN hwnd  - ðîäèòåëü.
  IN index - èíäåêñ âêëàäêè.
*/
static void loadTool(HWND hwnd, BYTE index)
{
  if(index != lastTool)
  {
    TOOLDATA *ct = &toolsList[index];
    CWA(user32, SetDlgItemTextW)(hwnd, IDC_TITLE, Languages::get(ct->lngId));
    if(lastTool != 0xFF)CWA(user32, ShowWindow)(toolsList[lastTool].hwnd, SW_HIDE);
    if(ct->hwnd == NULL)ct->hwnd = CWA(user32, CreateDialogParamW)(currentModule, MAKEINTRESOURCEW(ct->resId), hwnd, ct->dlgProc, NULL);
    lastTool = index;
    CWA(user32, ShowWindow)(ct->hwnd, SW_SHOW);
  }
}

/*
  Ôóíêöèÿ ãëàâíîãî îêíà.
*/
static INT_PTR CALLBACK mainDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch(msg)
  {
    case WM_INITDIALOG:
    {
      //Çàïîëíÿåì ñïèñîê âêëàäîê.
      {
        HWND hLB = CWA(user32, GetDlgItem)(hwnd, IDC_TOOLSLIST);
        for(BYTE i = 0; i < toolsCount; i++)CWA(user32, SendMessageW)(hLB, LB_ADDSTRING, 0, (LPARAM)Languages::get(toolsList[i].lngId));
        CWA(user32, SendMessageW)(hLB, LB_SETCURSEL, 0, 0);
      }

      //Çàãðóæàåì èêîíêó.
      {
        HICON hIcon = Gui::_loadSharedIcon(currentModule, MAKEINTRESOURCEW(ICON_MAIN));
        CWA(user32, SendMessageW)(hwnd, WM_SETICON, ICON_SMALL, (WPARAM)hIcon);
        CWA(user32, SendMessageW)(hwnd, WM_SETICON, ICON_BIG, (WPARAM)hIcon);
      }

      //Îòêðûâàåì âêëàäêó ïî óìîë÷àíèþ.
      loadTool(hwnd, 0);

      //Âûñòàâëÿåì çàãîëîâîê.
      CWA(user32, SetWindowTextW)(hwnd, Languages::get(Languages::main_title));
      break;
    }

    case WM_DESTROY:
    {
      for(BYTE i = 0; i < toolsCount; i++)if(toolsList[i].hwnd != NULL)CWA(user32, DestroyWindow)(toolsList[i].hwnd);
      break;
    }

    case WM_CLOSE:
    {
      //Ðàññûëàåì âñåì âêëàäêàì ïðåäëîæåíåíèå î çàêðûòèå.
      for(BYTE i = 0; i < toolsCount; i++)if(toolsList[i].hwnd)
      {
        if((bool)CWA(user32, SendMessageW)(toolsList[i].hwnd, WM_CANCLOSE, 0, 0) == false)return TRUE;
      }
      CWA(user32, EndDialog)(hwnd, 0);
      break;
    }

    case WM_COMMAND:
    {
      switch(LOWORD(wParam)) 
      {
        case IDC_TOOLSLIST:
          if(HIWORD(wParam) == LBN_SELCHANGE)loadTool(hwnd, (UINT)CWA(user32, SendMessageW)((HWND)lParam, LB_GETCURSEL, 0, 0));
          break;

        default:
          return FALSE;
      }
      break;
    }

    default:
      return FALSE;
  }
 
  return TRUE;
}
#endif

/*
  Òî÷êà âõîäà.

Doing Unit Testing

$
0
0
I am making some ids for the tiles of a grid in a game.
And I want to make a unit test module for regression testing.
But the data sometimes differ, I want to say test, when I give the unit test an id
it returns me with some neighbouring tiles.
However, when I change the program, all the ids change/shift up and down,
What are the general techniques to make test data consistent and predictable?

Should I make sure the bottom-up approach is used, so that I test lowest layer first.
And don't worry about it after gurranteeing it is correct.

C Programming for a Stack Also How to use Code Tags

$
0
0
/* The following program must be completed to perform the following

1. Implement a Stack ADT using and integer array
2. Write a main function to help test the stack


*/

#include <stdio.h>


#define MAXSIZE 5

typedef int Data;//
typedef Data Stack[MAXSIZE];


//prototypes


void push(Data element,int *top, Stack stk);//function to push element at the top of the stack
Data pop(int top, Stack stk);// function to pop data
int isFull(int top);// test to see if stack is full
int isEmpty(int top);//test to see if stack is empty


,int main()
{
//write the code to test the stack...
int isEmpty(int top);
int isFull(int top);


return 0;
}

//write the code the implement the functions listed above

int isFull(int top){

if(top==MAXSIZE){
printf("Sorry the stack is full");
return 1;
}
else
return 0;
}

int isEmpty(int top)
{
if(top<0)
return 1;
else{
return 0;
}
}

void push(Data element,int top, Stack stk)
{
if(isFull(top)){
printf("Sorry stack is full");
}
else
top++;
}

Data pop(int top, Stack stk)
{

if (isEmpty(top))
{
printf("Sorry the stack is empty");
getchar();
}
else{
stk=stk[top];
top--;
return top;
}
}

The error is in the last line

Preprocessor string (with space characters)

$
0
0
I've just noticed this problem with MSVC8 (I'm not sure if it also affects later versions...)

Suppose I open my project settings and navigate to Configuration Properties->C/C++->Preprocessor. I then add the following pre-processor definition;-

Code:

SOME_STRING="\"Hello World\""
Believe it or not, this stops the program from compiling! If I try to compile any source file in that project I see the following compiler error:-

Code:

c1xx : fatal error C1083: Cannot open source file: 'World"': Invalid argument
It makes no difference whether my pre-processor string ever gets used anywhere. The mere presence of a pre-processor string containing a space character causes the above compiler error. If I remove the space, everything compiles fine.

I'm totally baffled... Does this make sense to anyone here..?

Linker Error While migrating from VS 6 to VS 13

$
0
0
Hi ,

I am migrating my old visual studio 6.0 MFC AppWizard Project (XP Based) to Visual Studio 2013.

I have made the needed changes , compiles without errors or warning. While Linking it gives following Errors

Code:

1>Mailscheduler.obj : error LNK2019: unresolved external symbol "public: class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > __thiscall CPJNSMTPException::GetErrorMessage(void)" (?GetErrorMessage@CPJNSMTPException@@QAE?AV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@XZ) referenced in function __catch$?sendmailthread@@YAIPAX@Z$0
1>Mailscheduler.obj : error LNK2019: unresolved external symbol "public: __thiscall CPJNSMTPAddress::CPJNSMTPAddress(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const &)" (??0CPJNSMTPAddress@@QAE@ABV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) referenced in function __catch$?sendmailthread@@YAIPAX@Z$0
1>Mailscheduler.obj : error LNK2019: unresolved external symbol "public: int __thiscall CPJNSMTPBodyPart::SetFilename(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const &)" (?SetFilename@CPJNSMTPBodyPart@@QAEHABV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) referenced in function __catch$?sendmailthread@@YAIPAX@Z$0
1>Mailscheduler.obj : error LNK2019: unresolved external symbol "public: void __thiscall CPJNSMTPMessage::AddTextBody(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const &)" (?AddTextBody@CPJNSMTPMessage@@QAEXABV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) referenced in function __catch$?sendmailthread@@YAIPAX@Z$0
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (__imp_??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) referenced in function "public: class CString __thiscall CPJNSMTPAddress::GetRegularFormat(int,class CString const &)const " (?GetRegularFormat@CPJNSMTPAddress@@QBE?AVCString@@HABV2@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (__imp_?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) referenced in function "public: class CString __thiscall CPJNSMTPAddress::GetRegularFormat(int,class CString const &)const " (?GetRegularFormat@CPJNSMTPAddress@@QBE?AVCString@@HABV2@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CPJNSMTPBodyPart::QuotedPrintableEncode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?QuotedPrintableEncode@CPJNSMTPBodyPart@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(char const *)" (__imp_??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CPJNSMTPBodyPart::QuotedPrintableEncode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?QuotedPrintableEncode@CPJNSMTPBodyPart@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: char & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator[](unsigned int)" (__imp_??A?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAADI@Z) referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CPJNSMTPBodyPart::QuotedPrintableEncode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?QuotedPrintableEncode@CPJNSMTPBodyPart@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CPJNSMTPBodyPart::QuotedPrintableEncode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?QuotedPrintableEncode@CPJNSMTPBodyPart@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::substr(unsigned int,unsigned int)const " (__imp_?substr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV12@II@Z) referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CPJNSMTPBodyPart::QuotedPrintableEncode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?QuotedPrintableEncode@CPJNSMTPBodyPart@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(char)" (__imp_??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@D@Z) referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CPJNSMTPBodyPart::QuotedPrintableEncode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?QuotedPrintableEncode@CPJNSMTPBodyPart@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::allocator<char> const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$allocator@D@1@@Z) referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CPJNSMTPBodyPart::QuotedPrintableEncode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?QuotedPrintableEncode@CPJNSMTPBodyPart@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (__imp_??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) referenced in function "public: static int __cdecl CPJNSMTPBodyPart::ConvertToUTF8(class CString const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?ConvertToUTF8@CPJNSMTPBodyPart@@SAHABVCString@@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::length(void)const " (__imp_?length@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) referenced in function "public: int __thiscall CPJNSMTPBodyPart::GetBody(int,char * &,int &)" (?GetBody@CPJNSMTPBodyPart@@QAEHHAAPADAAH@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::replace(unsigned int,unsigned int,char const *)" (__imp_?replace@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@IIPBD@Z) referenced in function "protected: static void __cdecl CPJNSMTPBodyPart::FixSingleDotA(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?FixSingleDotA@CPJNSMTPBodyPart@@KAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned int const std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::npos" (__imp_?npos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@2IB)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::insert(unsigned int,char const *)" (__imp_?insert@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@IPBD@Z) referenced in function "protected: static void __cdecl CPJNSMTPBodyPart::FixSingleDotA(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?FixSingleDotA@CPJNSMTPBodyPart@@KAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl std::operator==(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (__imp_??8std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@PBD@Z) referenced in function "protected: static void __cdecl CPJNSMTPBodyPart::FixSingleDotA(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?FixSingleDotA@CPJNSMTPBodyPart@@KAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find(char const *,unsigned int)const " (__imp_?find@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDI@Z) referenced in function "protected: static void __cdecl CPJNSMTPBodyPart::FixSingleDotA(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?FixSingleDotA@CPJNSMTPBodyPart@@KAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>smtplibd.lib(PJNSMTP.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *,class std::allocator<char> const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDABV?$allocator@D@1@@Z) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall CPJNSMTPMessage::getHeader(void)" (?getHeader@CPJNSMTPMessage@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>.\Debug\TechTry.exe : fatal error LNK1120: 21 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


I read on MSDN and added lines for CStringT class . The file is as follows

Code:


// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__5E3191DA_46C4_4A67_B798_EFC4EDA3FC07__INCLUDED_)
#define AFX_STDAFX_H__5E3191DA_46C4_4A67_B798_EFC4EDA3FC07__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define VC_EXTRALEAN                // Exclude rarely-used stuff from Windows headers

#include <afxwin.h>        // MFC core and standard components
#include <afxext.h>        // MFC extensions
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h>                // MFC support for Internet Explorer 4 Common Controls

#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>                        // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <afxtempl.h>   

// Following 5 lines added for making sendmail possible
#include <afxsock.h>
#include <afxpriv.h>
#include <wincrypt.h>
#include <string>
#include <WinInet.h>



//{{AFX_INSERT_LOCATION}}
template class __declspec(dllimport) CStringT < TCHAR, StrTraitMFC < TCHAR, ChTraitsCRT <TCHAR> > >;
template class __declspec(dllimport) CSimpleStringT <TCHAR>;

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__5E3191DA_46C4_4A67_B798_EFC4EDA3FC07__INCLUDED_)


I am adding the template class lines explictly as suggested by msdn.

Still the problem is as written above.

Pl guide me how to insert the lines.

Thanking you

Two Flowcharts

$
0
0
Hi Guys, I have problem width draw two flowcharts. Please help me draw this flowcharts.Thanks!!!!

First:

Code:

for (i = j = n - 1; i >= 0; --i)
        {
                if (arr[i] != 0)
                {
                        if (i != j)
                                arr[j] = arr[i];
                        --j;
                }
        }
        for (i = 0; i <= j; i++)
                arr[i] = 0;

        cout << endl;
        cout << "New array: " << endl;
        for (i = 0; i < n; i++)
        {
                cout << arr[i] << " ";
        }


and second code:
Code:

mult = 1;
        for (int i = 0; i < n; i++)
        {
                for (int j = 0; j < m; j++)
                {
                        if (pp[i][j] < 0)
                                mult *= pp[i][j];
                        else
                                mult = 0;
                }
                if (mult)
                {
                        cout << "Sum: " << mult;
                        cout << endl;
                }
        }

How to draw a sphere with directx 9

$
0
0
Hi

I have drawn a cube using visual studio c++ and directx 9. Now I would like to draw a spere. Could you please send any example or tutorial how to draw other complex 3D objects?

Regards

std::map::at() versus std::map::find()

$
0
0
Using VC8 I'm trying to compile a program originally written for the gcc compiler. At one point it uses std::map::at(). MSVC does support std::map::at() but it wasn't introduced until VC10. So the nearest thing I have available is std::map::find(). This latter function returns an iterator (which I'd need to de-reference). But I can't quite figure out what std::map::at() returns. Does it also return an iterator or does it already de-reference it to return a value?

pdb-eam me up scotty?

$
0
0
I want to look at some crash dumps but can't due to mismatched dates between executibles and pdb files.

Apparently there was some data lost at some point and the restore software must have striped a bunch of restored files with the same date.

My issue is I have found some software that would fix possibly an older version of pdb...pdb7.0.

Is there a table that shows what Versions of Visual Studio used which version of PDB?

Anybody have any ideas here?

Your help is really appreciated.

How to close the main application by clicking on the console?

$
0
0
I spawned a console from the main application as a log window.
But when I clicked on the x of the main app, the application just won't stop execution.
When I clicked on the x of the console, it does stop, but memory leak remains.
I rechecked and discovered the destructor of the main application never got called
when I clicked on the close button of the console window.
how do I make sure I call on that no matter which window I close from?

I open a console like this

Code:

#include "CMyApp.h"
#include <crtdbg.h>

FILE* consoleWin = NULL;
 

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
        // check for memory leak
        int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
        flag |= _CRTDBG_LEAK_CHECK_DF;
        _CrtSetDbgFlag(flag);

       
        AllocConsole();
        consoleWin = freopen("CONOUT$", "w", stdout);
       

        CMyApp SimApp;       
       
        if (!SimApp.Create(hInst))
                return false;

        if (!SimApp.Run())
                return false;
       
        fclose(consoleWin);
       
       
        return 0;
}

LRESULT CALLBACK CSimApplication::WinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
        switch (uMsg)
        {
        case WM_CLOSE:               
        case WM_DESTROY:
                PostQuitMessage(0);
                break;
        case WM_KEYDOWN:
                switch (wParam)
                {
                case VK_F11: // error on F12???
                        PostQuitMessage(0);
                        break;
                }
                break;
        case WM_SIZE:
                // Check to see if we are losing our window...
                if (wParam == SIZE_MAXHIDE || wParam == SIZE_MINIMIZED)
                        CSimApplication::m_pGameApp->SetGameActive(false);
                else
                        CSimApplication::m_pGameApp->SetGameActive(true);
                break;
        case WM_ACTIVATE:
                if (LOWORD(wParam) == WA_INACTIVE)
                        CSimApplication::m_pGameApp->SetGameActive(false);
                else if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE)
                        CSimApplication::m_pGameApp->SetGameActive(true);
                break;
        case WM_ENTERSIZEMOVE:
                CSimApplication::m_pGameApp->SetGameActive(false);
                break;
        case WM_EXITSIZEMOVE:
                CSimApplication::m_pGameApp->SetGameActive(true);
                break;
        default:
                return DefWindowProc(hwnd, uMsg, wParam, lParam);
        }
        return 0;
}

After that, there is a log singleton to hold onto the log messages.
Thanks
Jack

List iterator is not incrementable

$
0
0
On the line
Code:

for (std::list<MSG_Object*>::iterator i = m_delayedMessages.begin(); i != m_delayedMessages.end(); ++i)
{

The i variable has become 0xcdcdcdcdcd, It doesn't happen immediately, it accumulates to about 18 messages in the start, and gradually delivered everything until there were 4 messages left. I look it up in the web which says it is an uninitialized variable of some sort. I didn't write this code, so I am not sure why that happens.
It seems to me that i has been initialized on this line, why the error still pops up?

The error happens also in the original program, I think it was written for VS9 or something, now I am using
VS2013 community.

Thanks
Jack

Code:

#include "msgroute.h"
#include "CObject.h"
#include "statemch.h"
#include "database.h"
#include "global.h"
#include "time.h"
#include "msg.h"



MsgRoute::MsgRoute( void )
{

}


MsgRoute::~MsgRoute( void )
{

}


void MsgRoute::SendMsg( float delay, MSG_Name name, objectID receiver, objectID sender, int state )
{

        if( delay <= 0.0f )
        {        //Deliver immediately
                MSG_Object msg( g_time.GetCurTime(), name, receiver, sender, state );
                RouteMsg( msg );
        }
        else
        {        //Check for duplicates - then store
               
                for (std::list<MSG_Object*>::iterator i = m_delayedMessages.begin();
                        i != m_delayedMessages.end(); ++i)
                {
                        if( (*i)->IsDelivered() == false &&
                                (*i)->GetMsgName() == name &&
                                (*i)->GetReceiver() == receiver &&
                                (*i)->GetSender() == sender &&
                                (*i)->GetMsgState() == state )
                        {        //Already in list - don't add
                                return;
                        }
                }
               
                //Store in delivery list
                float deliveryTime = delay + g_time.GetCurTime();
                MSG_Object * msg = new MSG_Object( deliveryTime, name, receiver, sender, state );
                m_delayedMessages.push_back( msg );
        }

}


void MsgRoute::DeliverDelayedMessages( void )
{
       
        for (std::list<MSG_Object*>::iterator i = m_delayedMessages.begin(); i != m_delayedMessages.end(); ++i)
        {
                float dtime = (*i)->GetDeliveryTime();
                float ctime = g_time.GetCurTime();
                if( (*i)->GetDeliveryTime() <= g_time.GetCurTime() )
                {        //Deliver and delete msg
                        MSG_Object * msg = *i;
                        RouteMsg( *msg );
                        delete( msg );
                        i = m_delayedMessages.erase( i );
                }
        }

}

void MsgRoute::RouteMsg( MSG_Object & msg )
{
        CObject * object = g_database.Find( msg.GetReceiver() );

        if( object != 0 )
        {
                if( msg.GetMsgState() < 0 ||
                        msg.GetMsgState() == object->GetStateMachine()->GetState() )
                {        //State was irrelevant or current state matches msg state (for msg scoping)
                        msg.SetDelivered( true );
                        object->GetStateMachine()->Process( EVENT_Message, &msg );
                }
        }

}

Hotkeys in C++ app suddenly stop working

$
0
0
Hi. We have a problem with our software that we’re struggling to fix. The app is a MFC C++ media player for Windows, the FTW Transcriber: http://www.theftwtranscriber.com/

Program users can use hotkeys to play files, including stop, rewind and forward functions. However, users who upgrade to Windows 10 sometimes experience problems with the hotkeys. They work for a while and then suddenly stop, and we don’t know why. Restarting the PC or reinstalling the software makes the hotkeys work for a while, but then they stop again.

While the hotkeys are working, F1 plays the file, as it should. After they stop working, F1 opens help. In other words, it appears that Windows 10 is stealing the keyboard input from our program. But it's strange that everything works fine at first but then stops for no obvious reason.

Most of the DEFAULT hotkeys are "F" keys, but the software allows them to be remapped to other keys, but they still don't work even after remapping. Any ideas why?!

Please note our question is not why the hotkeys don’t work – the question is why they DO work, and then STOP working.

Thanks!
Viewing all 3021 articles
Browse latest View live