Tales

This is the right way to do it:
[ICODE]
DateTime^ Date = gcnew DateTime();
Date = Date->Now;
[/ICODE]

Tales Light Poster

How can I initialise a Datetime^ variable with current Date?
I have this idea but I'm not sure:
[ICODE]
Datetime^ curDate = gcnew DateTime::Now;
[/ICODE]

Anyone?

Tales Light Poster

Hello, can anyone help me to finish this code?
[CODE]
ref class data_XML{
private:
int service_code;
wchar_t name;
wchar_t
address;
wchar_t phone;
wchar_t
fax;
wchar_t web_page;
wchar_t
city;
wchar_t additional_info;
wchar_t
specialty;
wchar_t* sub_specialty;
data_XML^ next_XML;
public:
// Constructor
data_XML(void){};
void next(data_XML^ next){ this->next_XML= next; }

virtual String^ ToString() override{
    String^ pointer = gcnew String(nombre);
    return pointer;
}

};
[/CODE]
Basically what I need is to finish te constructor because i'm not sure if i need to do something like [ICODE]gcnew data_XML();[/ICODE] when i call it.
In my main function i have
[CODE]
data_XML myFirstXML;
data_XML^ myNextXML;
myFirstXML.next(myNextXML);
[/CODE]
I don't know if it's right or wrong the way it is right now. Question: how do I add the 3rd elemento? Thanks for your help :D

Tales

Well, I wonder if I can get at least one answer, as no one seem to be interested in my thread. Was the question too stupid? or too complicated?
I would like to have any kind of answer to help me solve my problem or just delete all my project and start from scratch.

Thanks again (to whoever wants to answer something)

Tales

Why did you put your functions inside main() ?, I think you should move them out. (I'm not an expert, so maybe I'm wrong)
Result is an array of strings, when you use [ICODE]cout << "This answer is " << result << endl;[/ICODE] you must be getting something like:
This answer is Array or... something similar.

You need to tell the program which array will it show:
[ICODE]cout << "This answer is " << result[0] << endl;[/ICODE]

Tales

Are You allowed to use a class or a struct?
For example...
[CODE]
struct item{
int total; // To store the ammount of items of this product
string name; // The name of the product
string code; // If You wanna add a code to the product
item *next; // Pointer to the next item of the same type
};
[/CODE]
That way you can keep your items sorted very easy
Maybe someone else can make another suggestion?

Tales

I really don't know how to work with files this way, but i made a few changes to your code and it worked (i didn't check if the program was working correctly, just got rid of all the error messages).
Well, this were my small changes:

First, you need to include the [ICODE]string[/ICODE] library if you're going to use[ICODE] getline [/ICODE].
[ICODE]#include [/ICODE].

I also changed the return type of your functions and the parameter list: [ICODE]int load(char filename[], int items[], string names[]);[/ICODE], in this function You don't need to pass [ICODE]int &n[/ICODE], because you're turning it into 0 at the begining of the function, every time. Plus, your return type was int, so you need to return something of type integer. So, I put at the end of the function [ICODE]return n;[/ICODE]. And i the calling line, the code would look like this: [ICODE]n = load(filename, items, names);[/ICODE].

The add function is not returning anything, so i changed it to:
[ICODE]void add(char filename[], int items[], string names[], int& n)[/ICODE], remember that if you declare a function as int, it must return a value of type integer.

After this small changes, the program compiled well (no errors). Hopefully it is doing the work, the way it is supposed to do it.
I think I can create a new file and just use te add function to see if it works. If I find something I'll let You know.

Tales Light Poster

I built a Visual Studio 2008 VC++ project, dialog based using HTML.
In my HTML I have:
[CODE]

Choose the file which contains the information:

[/CODE]

The user is supposed to browse to a valid Excel file which I will work using the excellent [B]ExcelFormat library by Martin Fuchs[/B] to produce a XML output.
So, I try to capture the path to the file or at least something using the button loadExcel that will trigger a function:
[CODE]
BEGIN_DHTML_EVENT_MAP(CGeneraliDMDlg)
DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK)
DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
DHTML_EVENT_ONCLICK(_T("loadExcelButton"), OnLoadExcel)
END_DHTML_EVENT_MAP()
[/CODE]

And here is the code to my function so far:
[CODE]
HRESULT CGeneraliDMDlg::OnLoadExcel(IHTMLElement pElement){
BSTR bstrText = NULL;
GetElement(_T("myFileInput"), &pElement);
if(pElement){
pElement->get_innerText(&bstrText);
char
Text = _com_util::ConvertBSTRToString(bstrText);
AfxMessageBox(Text);
}
return S_OK;
}
[/CODE]

For some reason I don't understand, the Message box is empty, does it mean I'm not capturing anything? can someone give me a little help with this?
To tell the truth, I found the code for the OnLoadExcel function doing some research, but it does not work.
If I do something like [ICODE]pElement->put_outerHTML(blah)[/ICODE], it works perfect, so i think somehow i'm loosing my information in the way.

In advance, thanks for any help you can give me :D

Tales

I'm sure there are a lot of better answers than mine, just wanted to let you see it:
[CODE]
// i will be the limit to finish the recursion
// j will be the limit to paint the line
void triangle(int i, int j){
if(j < i){ // If the limit has not been reached
for(int a = 0; a < j; a++)
cout << "*";
cout << endl;
triangle(i, j + 1); // Recall the function with line limit increased
}
}
[/CODE]

Tales

[QUOTE]To use CSS files, JavaScript files and images in resource, you must convert all links in HTML file to be the resource numbers. Take a look at this article - [url]http://www.codeproject.com/KB/MFC/Im...spx?msg=953524[/url]
[/QUOTE]
Wow, thanks a lot, it did work great.

Tales

I did some work with your project. I know this is not what you're asking for, but I was bored waiting to see if someone could help with my question, and I decided to make something extra with your project. Hope You like it:

[CODE]
// The headers are still the same
//Michelle Stokes CSI130 Lab 13
//Code from hand out Lab14 TTT

include
include

using namespace std;
[/CODE]
Here you will notice that i changed your functions
[CODE]
// Function prototypes
void intro(void);
void printBoard(char [3][3]);
int move(char [3][3], int, int [9], int); // Now i only use 1 function to control the moves of computer and human player
int checkWinner(char [3][3], int); // This function checks if there is a winner on the game
bool checkLine(char [3]); // This other function checks if the elements of a char string are all the same
bool checkPosition(char [3][3], int, int); // This function checks if a given position is free

int main(void){
int user = 0, winner = 0, step = 0;
// Now i will use an array to control the random function
int positions[9] = {1, 2, 3, 4, 5, 6 , 7, 8, 9}; // I made this array to control the random function, because i noticed that the computer was taking too long to find a random free spot
int available = 9; // This is the new limit for random, it will decrease with every move played
// And this is my matrix ...

Tales

[CODE]

include // Includeing Headers
include
include

using namespace std;

void ShowIntroScreen(void), ShowInformation(double Money);
short GetBet(void), DoDiceThrow(void), GetAmount(void);
double DoMoneyCalc(short Dice, short Bet, short BetMoney);

int main(void){
double MoneyEarned, Money;
unsigned short BetMoney;
short DiceValue, Bet;

ShowIntroScreen();
Money = 1000;

do{
    ShowInformation(Money);

    Bet         = GetBet();
    BetMoney    = GetAmount();
    DiceValue   = DoDiceThrow();
    MoneyEarned = DoMoneyCalc(DiceValue, Bet, BetMoney);

    Money -= BetMoney;

    if(MoneyEarned == 0){
        cout << "You have lost.  The number was: " << DiceValue << endl << endl;
    }
    else{
        cout << "You won " << MoneyEarned - BetMoney;
        cout << " dollars. Number was: " << DiceValue;
        cout << endl << endl;

        Money += MoneyEarned;
    }
} while (Money > 100);

cout << "Game Over. Keep $" << Money << " for the ride home\n";
return 0;

}

void ShowIntroScreen(void){ // Rules and Start Up
cout << " Welcome to Craps 1.0" << endl << endl;
cout << " Here are the rules:" << endl << endl;
cout << "You have 1000 dollars to start gambling. ";
cout << endl << endl;

cout << "There are three types of bets. You can bet on: " << endl << endl;
cout << "  - 2 and 12 which will give you the ratio of 5 to 1 if you win.\n";
cout << "  - 4 and 10 which will give you the ratio of 2.5 to 1 if you win.\n";
cout << "  - 6 and 8 which will give you the ration of 1.5 and 1 if ...

Tales

I saw the following in your code:

  • You're missing the closing parenthesis of GetBet(void)
  • You're also missing the opening parenthesis on the switch(Bet) in DoMoneyCalc()
  • You are using break; break; in the switch(Bet) statement, you only need 1 break;
  • Also in the switch(Bet) you have default; but you need to use default: (notice the : )

You should add main() type int

Tales

[QUOTE=confusedndazed;1052866]I apologize, yes that's what I meant. Did you find any other issues with my pseudocode?[/QUOTE]
Your code is good :D

Tales Light Poster

I'm making a project in Visual studio 2008.
The details of the project are:

  • It is a MFC Application
  • The application type is Dialog based with Use HTML Dialog enabled
  • The project style is MFC standard and...
  • The use of the MFC is in a shared DLL

When it creates the project, I have an HTML file called myApp.htm
which contains the HTML code of the dialog.

I want to apply an external css file to this HTML, so i add:

in the head of the document. But it doesn't work.
So I try using:

but it doesn't work either.
I think there must be a way to do it.
I added the css file to the project.
I have tried everything, but no luck. Can someone give me a hand?
thanks!

Tales Light Poster

I have an Excel file with M columns (A, B, ..., M) that i need to open to extract it's contents using a visual c++ program. Does anyone know how to do it?
The last row of the file is line 423 (first row contains the headers of each column). Any help would be appreciated!

Tales Light Poster

Hello, I wanted to ask about a new small program that ihave to do.
I am supposed to take some information from an excel (the structure of this excel is fixed) and save it as an XML.

I am still deciding if I should do it with Visual C++ (which I know a little, but don't know how to interact with Excel) or Visual Basic (which I would have to read a book, but I read that it has communication with Excel already).

I appreciate any suggestions and guidance

Tales

The code works perfect in DEV C++, but it does not for VC++ (I am running Visual Studio 2005).

Tales Light Poster

For those who want to learn about windows, I leave the code I was looking for...

"Programatically filling a ComboBox and setting it visible or invisible"

[code]
HWND hWndComboBox[10];
char numChar[20]; // String that contains a number converted to string
int yPos = 160, xPos = 60;
int counter1, counter2; //
switch(Msg){
case WM_INITDIALOG:
for(counter1 = 0; counter1 < MAX_COMBOS; counter1++){
hWndComboBox[counter1] = CreateWindow("COMBOBOX", NULL, WS_CHILD | [B]WS_VISIBLE[/B] | WS_TABSTOP | CBS_DROPDOWN | WS_VSCROLL, xPos, yPos, 60, 60, hWndDlg, NULL, hInst, NULL);
if(!hWndComboBox){
MessageBox(hWndDlg, "Could not create the combo box", "Failed Control Creation", MB_OK);
return FALSE;
}
// I'll fill the ComboBoxes with numbers from 1 to LAST_NUMBER
for(counter2 = 1; counter2 <= LAST_NUMBER; counter2 ++){
itoa(counter2 , numChar, 10);
SendMessage(hWndComboBox[counter1], CB_ADDSTRING, 0, reinterpret_cast((LPCTSTR)numChar));
}
}
return TRUE;
}
...
...
[/code]
I would like to thank the ones who "made the effort to answer me"... even if it was only to tell me that they didn't know how to do it

"Sometimes is better to say I don't know..."

Tales

Still no answer? Please this is really important and I'm stuck...

Tales

I still wonder why nobody helps me... ?
As far as I know, i'm not asking people to do my work... just to help me figure a way to solve it

Tales Light Poster

I have this dialog box:
[code]
IDD_GRUPO_NOMBRAR DIALOGEX 447, 19, 226, 263
STYLE DS_SETFONT | DS_SETFOREGROUND | WS_POPUP | WS_CAPTION
EXSTYLE WS_EX_CONTEXTHELP | WS_EX_CONTROLPARENT
CAPTION "Nombrar grupos"
FONT 8, "Tahoma", 400, 0, 0x0
BEGIN
CTEXT "Por favor numere los grupos",IDC_STATIC,65,8,92,8
GROUPBOX "Los grupos iguales deben tener el mismo nombre",IDC_STATIC,16,24,189,212,BS_CENTER | BS_FLAT,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR1,20,38,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR2,20,57,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR3,20,76,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR4,20,95,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR5,20,114,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR6,20,133,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR7,20,152,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR8,20,171,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR9,20,190,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_NOMBRAR10,20,209,84,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
COMBOBOX IDC_COMBO1,137,37,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO2,137,56,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO3,137,74,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO4,137,93,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO5,137,112,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO6,137,131,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO7,137,150,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO8,137,169,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO9,137,188,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO10,137,206,48,30,CBS_DROPDOWN | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Aceptar",IDOK,59,242,50,14
PUSHBUTTON "Cancelar",IDCANCEL,113,242,50,14
END
[/code]
Can anyone tell ...

Tales

if((a%b)==0){multiple}
else{not multiple}

examples:
6%3 = 0
5%3 = 2
21%7 = 0
24%7 = 3

Tales Light Poster

Hi all, finally the first part of my program is working, it plays a MIDI melody extracted from a database. How did I do it? A little MySQL++ and the Play midi voice article posted in the code snippets.

But now I'm facing a problem... I am supposed to play the melody using the instrument 24 which is a Nylon string guitar, and it is supposed to have clean sounds, but they all come cut whenever I play them.

The partiture has figures lenght of 1/3 of black figure... about 167 miliseconds between notes, but everytime a note is going to start, the other one stops.

How can I solve this? How can I play one note while the other one is fading?

Sound(myGroupNotes[counter1].getFreq(counter2), 167, 127, 24);

If I need to open a new MIDI channel, how can I do it?

Help!

Tales

Well, I did this:

char myCharVar[MAX_CHAR];
(TCHAR)myCharVar

I know this is not a very good practice, but I couldn't find a better wayand I am in a hurry with this program...

Tales Light Poster

I need to find a way to convert char[] to TCHAR[]

I did my best to find it, but all I could find was char[] to wchar_t[]

using...

int swprintf( wchar_t buffer, const wchar_t format [, argument] ... );

Help please!

Tales Light Poster

I have been member since few weeks ago, but I didn't introduce myself to the comunity. So here I am, my name is Andres, I am from Colombia and I have a lot of questions about C++

I am a web developer, with some knowledge in HTML, PHP, MySQL and ActionScript. Right now I work with a partner who doesn't speak any english, but he is a cool guy.
Anything I can do, related to those 4 web languages I will be glad to help.

So, again... I will be happy if You can help me out with my C++ specially right now that I'm working in a complex desktop project (at least for me) which involves MySQL and MIDI

Oh... I wanted to suggest a chat for the site. It would be very useful, specially when someone is looking for a fast answer.

Thank You again

Tales

Is there a way to return the values of a Note?

I mean something like:

Note Note::getNote(){
return //Note values Freq and milisec
}

Tales Light Poster

Can someone help me with this?

class Note{
private:
[INDENT]double Freq;
int milisec;
[/INDENT]public:
[INDENT]Note();
Note(double Fr, int ms){
[INDENT]Freq = Fr;
milisec = ms;
[/INDENT]};
~Note();
[/INDENT]};

Ok... now I declare something like this:

Note mynotes[MAX_NOTES];

is there a way to find out the array size?

Thanks

Tales Light Poster

I want to make a query in C++ using the MySQL++ API.

Here is my problem, in PHP for example I make something like this:

$query = "SELECT * FROM table1 WHERE id = " . $value;

In C++ I can't do that. I need a way to make $value be part of the query string. I know it is a silly question, but can someone help me find this answer?

Thank You