|
i am a novice in game programming and i want to ask how
a program can read two keys simultaneously.
|
|
|
|
|
Direct Input, part of DirectX.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Train free @Microsoft
Got to this link and register free for
training your self for VS2005
https://www.microsoftelearning.com/visualstudio2005/
or
http://www.financialexpress.com/latest_full_story.php?content_id=107645
Microsoft dont give anything free except training
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hello...
I am having trouble setting the initial size of my SDI application. I thought that I would be able to override the PreCreateWindow() function in my MainFrame and reset the values of the CREATESTRUCT like this:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.cx = 1000;
cs.cy = 730;
if(!CFrameWnd::PreCreateWindow(cs))
return false;
return TRUE;
}
However, this does not work. I also tried the MoveWindow() function and SetWindowPos() function in the OnSize of CMainFrame. That looks like this..
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cy, cy);
if(!m_ResizeFlag)
{
MoveWindow(300, 300, 1000, 730);
m_ResizeFlag = true;
}
}
This did not work, either..
Any help would be MUCH appreciated!
Thanks in advance!
~SheriMarie
|
|
|
|
|
I add #include <windows.h> to stdafx.h file in windows form application and it dosent want to compile the project issuing this:
error C2039: 'GetObjectW' : is not a member of 'System::Resources::ResourceManager'
for this piece of code:
this->Icon = (__try_cast<system::drawing::icon *="">(resources->GetObject(S"$this.Icon")));
I just assigned new icon to my application and this code was added atomatically, but without #include <windows.h> it is compiled normally?
9ine
|
|
|
|
|
undefine GetObject and define a GetObject_T macro for calling the GetObjectA and GetObjectW API.
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
would you please indicate where should I undefine this macro and how to define another GetObject_T
9ine
|
|
|
|
|
another error with this code?
MessageBox::Show(this, S"err");
error C2653: 'MessageBoxW' : is not a class or namespace name
9ine
|
|
|
|
|
#undef MessageBox
#undef GetObject
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
Hi Folks,
I got a Wrapper Dll around a native C++ static library. In .NET 1.1 this
worked fine. When moving to .NET 2.0 I get a couple of unresolved externals /
linker errors:
Error 16 error LNK2028: unresolved token (0A000007) "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public:
virtual __thiscall std::logic_error::~logic_error(void)"
(??1logic_error@std@@$$FUAE@XZ) Parameter.obj
Error 17 error LNK2028: unresolved token (0A000007) "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public:
__thiscall std::bad_alloc::bad_alloc(char const *)"
(??0bad_alloc@std@@$$FQAE@PBD@Z) Imagic.obj
Error 18 error LNK2028: unresolved token (0A000008) "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public:
virtual __thiscall std::logic_error::~logic_error(void)"
(??1logic_error@std@@$$FUAE@XZ) Align2D.obj
Error 19 error LNK2028: unresolved token (0A000347) "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) referenced in function "public: virtual void
* __thiscall std::logic_error::`vector deleting destructor'(unsigned int)"
(??_Elogic_error@std@@$$FUAEPAXI@Z) Parameter.obj
Error 20 error LNK2028: unresolved token (0A0003D3) "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) referenced in function "public: virtual void
* __thiscall std::bad_alloc::`vector deleting destructor'(unsigned int)"
(??_Ebad_alloc@std@@$$FUAEPAXI@Z) Imagic.obj
Error 21 error LNK2028: unresolved token (0A000358) "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) referenced in function "public: virtual void
* __thiscall std::logic_error::`vector deleting destructor'(unsigned int)"
(??_Elogic_error@std@@$$FUAEPAXI@Z) Align2D.obj
Error 22 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ"
(?.cctor@@$$FYMXXZ) Align2D.obj
Error 23 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ"
(?.cctor@@$$FYMXXZ) AssemblyInfo.obj
Error 24 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ"
(?.cctor@@$$FYMXXZ) Imagic.obj
Error 25 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ"
(?.cctor@@$$FYMXXZ) Parameter.obj
Error 26 error LNK2019: unresolved external symbol "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public:
virtual __thiscall std::logic_error::~logic_error(void)"
(??1logic_error@std@@$$FUAE@XZ) Align2D.obj
Error 27 error LNK2001: unresolved external symbol "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) Imagic.obj
Error 28 error LNK2001: unresolved external symbol "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) Parameter.obj
Error 29 error LNK2019: unresolved external symbol "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) referenced in function "public: virtual void
* __thiscall std::logic_error::`vector deleting destructor'(unsigned int)"
(??_Elogic_error@std@@$$FUAEPAXI@Z) Align2D.obj
Error 30 error LNK2001: unresolved external symbol "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) Imagic.obj
Error 31 error LNK2001: unresolved external symbol "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) Parameter.obj
Error 32 fatal error LNK1120: 9 unresolved externals Debug\empDll.dll
In my .NET 1.1 Project I had to make the following Linker Settings to build
the DLL:
1.) Additional Dependencies: mscoree.lib msvcrt.lib (or msvcrtd.lib for
debug version) mystaticlib.lib
2.) Ignore Specific Library: nochkclr.obj
3.) Force Symbol Reference: __DllMainCRTStartup@12
In my Wrapper Classes I had to add the following:
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
This does not work any longer with the new Visual Studio and the new .NET
Framework.
The only article that I was able to find on this subject:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/TransGuide.asp
Doesn´t mention Linker settings at all.
Could anybody please help me or tell me where to go for further reading?
Thanks in Advance for your efforts.
Chucker
|
|
|
|
|
Building Q3.obj.
Building WeekOne.exe.
POLINK: error: Symbol '_main' is multiply defined.
*** Error code: 1 ***
Done.
Im doing this simple program and i got this error after executing. Below is the code. Please help.
_____________________________________________________________________________
#include <stdio.h>
int main ( ) {
int gross_sales;
int earnings;
int counter;
earnings = 200;
counter = 0;
while ( counter !=7 ){
printf("\nEnter Gross Sales:");
scanf("%d", &gross_sales );
counter = counter + 1;
}
earnings = 200 + 0.9*gross_sales;
printf("\nTotal earnings for last week is %d:\n", earnings);
return 0;
}
|
|
|
|
|
did you created an empty project or used the wizard ?
if you've choosen the later, the wizard may have already defined the main() function somewhere in the code - as the error tells us.
one question though, what was the file #include d ? stdio.h ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi, I have the following code
Stream *stream = File::Open(fileCFDPath, FileMode::Open, FileAccess::Read);
this->XmlStream = stream;
XPathDocument *doc = new XPathDocument(stream);
this->XmlStream->Position = 0;
The code breaks since XPathDocument automatically closes the stream, how could I clone the stream in order that I have a copy of the stream and I dont have to go and bring from disk the info again??
Thanks in advance
Isaac B
|
|
|
|
|
to clone an object is a java (or .NET) naming. in C++, where variables are not necessarily handled by reference, everything is done in the constructor (if it is well written of course )
so, something like the following should work :
Stream* s1 = ;
Stream s2 = new Stream(*s1);
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I need help with my orderedlist.cc. In the end we are to produce a sorted word dictionary which will reads words in and output them in sorted form. This is just two of the files. I also have KeyValue.h, KeyValue.cc staticHTable.h, staticHTable.cc.
This is the provided h file given:
<br />
include <string><br />
#include "KeyValue.h"<br />
using namespace std;<br />
<br />
class OrderedList<br />
{<br />
public:<br />
OrderedList();
~OrderedList();
<br />
<br />
void insert( string word, string definition);<br />
<br />
<br />
const string inspect( string w ) const;<br />
<br />
bool isIn( string w ) const;<br />
<br />
bool isEmpty() const;<br />
<br />
void printEntry() const;<br />
<br />
public:<br />
KeyValue* head;<br />
};<br />
the cc file of it of which i have done some but struggling to do and understand the next bits!
<br />
#include <iostream><br />
#include <stddef.h><br />
#include "OrderedList.h"<br />
#include <string> <br />
<br />
using namespace std;<br />
<br />
KeyValue::KeyValue()<br />
{<br />
word = "\0";<br />
definition = "\0";<br />
next = NULL;<br />
}<br />
<br />
OrderedList::OrderedList()<br />
<br />
{<br />
head = NULL;<br />
}<br />
<br />
OrderedList::~OrderedList()<br />
{<br />
KeyValue* Current;<br />
KeyValue* it;<br />
<br />
it = head;<br />
while (it != NULL);<br />
<br />
{<br />
Current = it;<br />
it = it->next;<br />
delete Current;<br />
}<br />
}<br />
<br />
bool OrderedList::isEmpty() const<br />
{<br />
return head == NULL;<br />
}<br />
<br />
<br />
<br />
void OrderedList::insertBefore(const int newval, const int val)<br />
{<br />
KeyValue* p = new KeyValue;<br />
KeyValue* iterator = NULL; <br />
KeyValue* previous = NULL;<br />
<br />
p->word = newval;<br />
p->next = NULL;<br />
if (isEmpty())<br />
{<br />
cout << "List is empty\n";<br />
}<br />
else<br />
{<br />
for (iterator = head; iterator != NULL; iterator = iterator->next)<br />
{<br />
if (iterator->word == val) <br />
{<br />
if (iterator == head)<br />
{ <br />
head = p;<br />
}<br />
else<br />
{<br />
previous->next = p;<br />
}<br />
p->next = iterator;<br />
break;<br />
}<br />
else <br />
{<br />
previous = iterator;<br />
}<br />
}<br />
}<br />
}<br />
<br />
void OrderedList::printEntry() const<br />
{<br />
if (isEmpty())<br />
{<br />
cout << "List empty" << endl;<br />
}<br />
else
{<br />
KeyValue* p = NULL;<br />
for (p=head; p!=NULL; p=p->next)<br />
{<br />
cout << p->word << endl; <br />
}<br />
}<br />
}<br />
i need help in doing the const string inspect( string w ) const; function and bool isIn( string w ) const becasue i really dont know how to do this to matter how much i have a go at it. Also what would be helpful if someone could also check that i have done everything right in the cc coding becasue i have got some errors for it! Also do i need to include a main program for this. I can also provide the KeyValue.h and KeyValue. files if needed.
Thanks (Hopefully you will be able to help me on this cos i have been finding this very very hard.
|
|
|
|
|
Hi! I am a bit stumped..
I am a fairly new MFC programmer, and I am creating a form-based application with mulitiple tabs. I am using the CTabCtrl class to create the tabs. Those work great, and I can even switch back and forth between tab views when I click on the tabs, but when I resize the main window the tabs have a static size. I would love it if the tabs also resized. Each of my tabs are dialogs.. I am not sure if that matters.
I did create an ON_WM_SIZE() message handler, and when the main window is resized, the breakpoint stops there. So I figure I need to add code in this message handler somewhere:
<pre)
void cresizeview::onsize(uint="" ntype,="" int="" cx,="" cy)
{
="" if(ntype="" !="SIZE_MINIMIZED" &&="" (cx=""> 0) && (cy > 0))
{
// Resize tabs????
}
CFormView::OnSize(nType, cx, cy);
}
I know I also need to somehow obtain a pointer to my tabs which are within the view. Not sure how to do that. One of the many reasons I am so confused.. any help would be greatly appreciated!!
~Sheri
|
|
|
|
|
|
Hi,
How do I overload operator[] such that when i have the following statement in my program:-
a[10][20][3]; //any number of dimensions
The requirement is :
1) i should be able to accept the values in the subscript operators.
2) With those values, i should be able to allocate memory dynamically in my operator[] function.
3) the function should be able to accept variable number of arguments(here, a[3][2][3][2]; has four arguments....namely a,3,2,3,2).
please help me.
PK
|
|
|
|
|
an alternative to such a behavior is to overload the operator () instead, but i conceed, you will have a fixed number of dimension...
i don't think overloading the operator [] is possible for such a thing, because look :
if you have myType t[10];
[] will work on a myType array (every thing fine so...)
but with myTpe t[10][20];
the second [] will work on a myType[10] array... now, everything goes hard because you would have to overload as many versions of the [] as you want for the first dimension !!!
imagine myType[10][20][30];
the 3rd [] works on a myType[10][20] array !!!!!!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: i don't think overloading the operator [] is possible for such a thing,
Why? This will work for infinite dimensions.
class A
{
public:
A operator [](int index)
{
A a;
return a;
}
};
Of course, it'll be tough to code the body of the function, as you won't know which dimension you are in.
Oh, in myType[10][20], the second dimension operates on whatever was returned by the first [], so it's not really overloading for myType[10].
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
-- modified at 4:35 Saturday 5th November, 2005
|
|
|
|
|
For a 2-D situation the easiest thing to do is something like this:
<code>
Array of arrays of ints
typedef vector<vector<int> > CMultiIntArray;
void TraceDynamicArray(const unsigned int rows, const unsigned int columns)
{
CMultiIntArray aTest;
// Allocate number of rows
aTest.resize( rows );
// For each row
for (int row = 0; row < aTest.size(); row++)
{
// Allocate number of columns
aTest[row].resize( columns );
// For each column
for (int column = 0; column < aTest[row].size(); column++)
{
// Assign a value
aTest [row] [column] = 10 * row + column;
// Trace it
cout << aTest [row] [column] << "\t";
}
cout << "\n";
}
}
// Example usage: Standard C++ Library version
int main(int argc, char* argv[])
{
TraceDynamicArray(3,5);
return 0;
}
// For rows = 3, columns = 5, produces output...
// 0 1 2 3 4
// 10 11 12 13 14
// 20 21 22 23 24
</code>
Then you can do something similar for higher dimensions. But you have to define the dimensions upfront.
Kevin
|
|
|
|
|
I have a question. I wrote and array of 5 structs into a binary file. I need to be able to go to a specific position in a binary file and overwrite that struct with another. I have tried it but when i go to overwrite the struct the ones before it all the data is screwed up.Can anyone help me on how to overwrite a specific person in the file.
struct PERSON
{
int age;
int weight;
char name[25];
};
void write_names() //WRITES 5 PEOPLE TO THE FILE
{
ofstream out;
PERSON p[5];
int ct;
p[0].age = 1;
p[0].weight = 1;
strcpy(p[0].name, "Num_1");
p[1].age = 2;
p[1].weight = 2;
strcpy(p[1].name, "Num_2");
p[2].age = 3;
p[2].weight = 3;
strcpy(p[2].name, "Num_3");
p[3].age = 4;
p[3].weight = 4;
strcpy(p[3].name, "Num_4");
p[4].age = 5;
p[4].weight = 5;
strcpy(p[4].name, "Num_5");
out.open("file.dta", ios::binary);
for (ct=0; ct<5; ct++)
out.write((char*)& p[ct], sizeof(p[ct]));
out.close();
}
void show_names() //SHOW ALL THE PEOPLE IN THE FILE
{
ifstream f;
f.open("file.dta", ios::binary);
PERSON p[10];
int ct;
int num = 0;
while(!f.eof())
{
f.read((char*)& p[num], sizeof(p[num]));
num++;
}
num--;
for(ct=0; ct
|
|
|
|
|
you need to use ios::binary|ios::_Nocreate as the open mode when you do the open to replace the second person
|
|
|
|
|
Basically I have two programs... the first program as you to input a total number of variables you want... max of 8.. then it ask you for its value... after it does all that it ask you if you want to add subtract mult or divide... then once all that is done it out puts to a file of your choice(what you name it)
LOOKS LIKE
a 1
b 2
c 3
d 4
e 5
f 6
g 8
h 10
add
a b
sub
d e
mul
e a
div
c d
and so on.... my problem is in my second program im trying to read the values in the being able to read in the command add sub div or mul... i attempt while(!fin.eof()) and read in the opperation add,sub and so on then the 2 variables like a b c d e f and so on... then run a bunch of if statesments to test if they match and once it does it outputs the answer.. the i want it to go to the next line...and read in next opperation and 2 variables and compute but it usually fails...
heres sample code...
#include <iostream>
#include <fstream>
#include <iomanip>
//dynamic memory
using namespace std;
int main()
{
ifstream fin;
ofstream fout;
char filename[20];
int pause,x,y,z;
int int1,int2,int3,int4,int5,int6,int7,int8;
char char1,char2,char3,char4,char5,char6,char7,char8;
string opp1[x];
char aa[x];
char bb[x];
x=0;
cout <<"Please enter the filename that you created to store"<<endl;
cout="" <<"information="" in="" the="" first="" program.="" ex:="" c:\data.txt"<<endl;
="" cin="">>filename;
fin.open(filename, ios::in);
cout<<"This is my awesome program:"<<endl;
if="" person="" doesnt="" enter="" all="" 8="" variables="" then="" they="" fill="" with="" zeros
="" int1="0;
" int2="0;
" int3="0;
" int4="0;
" int5="0;
" int6="0;
" int7="0;
" int8="0;
" char1="0;
" char2="0;
" char3="0;
" char4="0;
" char5="0;
" char6="0;
" char7="0;
" char8="0;
" fin="">> char1 >>int1;
fin >> char2 >>int2;
fin >> char3 >>int3;
fin >> char4 >>int4;
fin >> char5 >>int5;
fin >> char6 >>int6;
fin >> char7 >>int7;
fin >> char8 >>int8;
cout <<char1 <<"=" <<int1 <<endl;
cout <<char2 <<" =="" "="" <<int2="" <<endl;
="" cout="" <<char3="" <<int4="" <<char5="" <<int6="" <<char7="" <<int8=""
="" while(!="" fin.eof())
="" {
="" fin="">> opp1[x];
//cout <<opp1[x] <<endl;
="" fin="">>aa[x];
//cout <<aa[x]<<" ";
="" fin="">>bb[x];
//cout <
|
|
|
|
|
Hello,
i a little newbie to C++. So sorry for some stupid questions.
The following scenario:
We have a java application running on 200 pcs in a network enviroment. If a user starts the app the complete jre has to be loaded from a mounted network volume. This took about 20 to 40 sec. We cannot change this...
So currently i'm trying to write a splash screen which is showing the user that something is going on.
The splash screen is implemented. Now my question. Is there an easy way to lauch a jar as a process from c++ in that way that the splash screen waits until the java app is started?
Are ther tutorials in the web available?
Thanks for any help.
Regards,
Carsten
University of Konstanz
|
|
|
|
|