|
Ok I am just starting out in c++ and I had a question -
I have been making some tiny programs where a little guy runs around - cheesy yeah. The way I've been printing out him and the playing field is basically a 2-d array filled with the map and him... Then in DOS evertime a player moves I just reprint out the whole thing. Now I THINK I am ready to use graphic to make it all a little better....
..The thing is I've been downloading all these free libraries/includes/tutorials/etc.. but when it comes time to compile them I ALWAYS get errors! These are the author's original files I think maybe I am going about putting their files into my library/include/whatever the wrong way. What I have been doing is taking all their H files and just putting them into my include. Is this wrong? Is my compiler jacked? Should I leave it intact and perhaps add the unzipped folder (containing their source and h files) to my linkers directories? What the hell am I doing wrong!
Thanks for any help in advance. I am crying over this because I could have had like 5 games done in the time I have spent on this issue. You can email me at ontheritz@yahoo.com
Mike
OH PS Is there a way besides getch() to directly read keystrokes? Like I want to be able to know when the key is pressed as well as released. Is it somehow sneaking into the keyboard buffer and altering it yourself or what? How about the joystick/etc?
|
|
|
|
|
Usually libraries will involve one or more .h files in a directory. When C++ is looking for a .h file invoked by an include with <xxxx.h> it searchs a list of directories which is set somewhere in the options stuff. An include with quotes checks the source directory first. So the proper way of accessing a library is to include the directory with the headers in the header search path, not to put the headers into your source or copy the contents of them. (Obviously your own code must invoke them with a
<br />
#include <xxxx.h><br />
The linker has it's own, seperate list of libraries to search. You'll need to add the .lib files to your project.
As to getting user actions, if you're doing games you should probably be looking at the DirectInput library. That's what it's there for.
|
|
|
|
|
I am developing a program in eVC and for some reason I am getting these unresolved externals, any ideas? Also, it worked before but suddenly no more.
unresolved external symbol "protected: virtual long (__cdecl** __cdecl CWnd::GetSuperWndProcAddr(void))(void *,unsigned int,unsigned int,long)" (?GetSuperWndProcAddr@CWnd@@MAAPAP6AJPAXIIJ@ZXZ)
unresolved external symbol "public: virtual void __cdecl CFrameWnd::OnUpdateFrameMenu(void *)" (?OnUpdateFrameMenu@CFrameWnd@@UAAXPAX@Z)
unresolved external symbol "public: virtual void * __cdecl CFrameWnd::GetDefaultAccelerator(void)" (?GetDefaultAccelerator@CFrameWnd@@UAAPAXXZ)
unresolved external symbol "public: virtual void __cdecl CFrameWnd::DelayUpdateFrameMenu(void *)" (?DelayUpdateFrameMenu@CFrameWnd@@UAAXPAX@Z)
unresolved external symbol "public: void * __cdecl CFrameWnd::InsertMenuW(unsigned short const *)" (?InsertMenuW@CFrameWnd@@QAAPAXPBG@Z)
unresolved external symbol "public: void * __cdecl CWnd::GetSafeHwnd(void)const " (?GetSafeHwnd@CWnd@@QBAPAXXZ)
unresolved external symbol "public: virtual void * __cdecl CDocument::GetDefaultMenu(void)" (?GetDefaultMenu@CDocument@@UAAPAXXZ)
unresolved external symbol "public: virtual void * __cdecl CDocument::GetDefaultAccelerator(void)" (?GetDefaultAccelerator@CDocument@@UAAPAXXZ)
MIPSDbg/OLEDBCE.exe : fatal error LNK1120: 8 unresolved externals
Error executing link.exe.
Any help is greatly appreciated.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I think adding MFC42.lib in your lib path would help.
HTH
Jignesh
|
|
|
|
|
MFC42.lib is for the desktop. I am using embeddedVC++ which the lib is called mfcce211.lib which is already being linked. Thanks though.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I have had the same problem. I resolved the linking errors you are experiening by adding the libraries I needed as dependencies on the current project. This allowed it to access there objects that it needed. The trouble I later ran into was the code wanted a link to a pre-defined term that should be there according to the #include and the library. The funny thing was that it was only an error in debug. Sean
|
|
|
|
|
Sigh. There is always some truth to measure twice and cut once. Upon looking back, I found that I had included the libraries I need in the release copy but not in the Debug. The problem I have run into is that there is no one else in my office that does C++ so if I don't have someone to ask. Glad this forum was here, my program is working now. Sean
|
|
|
|
|
Hello all,
I am a new C++ programmer, and have run into a behavior that I don't understand. Consider the following code:
#include <iostream>
using namespace std;
int aArray[] = {20, 30, 40, 50, 60, 70}; // Create a test array
int myFunc(int *ara); // Func Prototype
void main(void)
{
myFunc(aArray);
return;
}
int myFunc(int *ara)
{
cout << endl << "Address of aArray: " << aArray;
// Returns a memory address.
cout << endl << "Size of aArray: " << (sizeof aArray);
// Returns 24, as expected.
cout << endl << "Address of ara: " << ara;
//Returns same address as aArray, above.
cout << endl << "Size of ara: " << (sizeof ara);
// !! Returns 4. Why is this?
// Does sizeof not work with a pointer passed to a function?
cout << endl;
return 0;
}
In all of the "Beginning C++" manuals I have looked at, the examples show passing the size of the array as an additional parameter to the function. This does address the issue I am dealing with here, but it seems more elegant to be able to interogate the array size **inside** the function. Can someone shed some light on this, please?
Thanks in advance,
|
|
|
|
|
In the first case the compiler knows that you are looking for the size of the array and the data type is int[]. The second time, it is an int* and the size of any pointer is 4 bytes.
--Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
couldn't you do sizeof(*ara)?
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I am programming using the dialog exe application wizard. I have a dialog box with a scrollbar on it and some edit boxes. The edit boxes have a range of 0 to 100, so if you enter a
number outside that range and kill focus a message comes up and focus goes back to the box.
My OnVScroll function looks like this:
void CWeightDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
m_edit2_ctrl.SetFocus();
int Pos = m_scrollWeights.GetScrollPos();
UpdateData();
switch(nSBCode)
{
case SB_LINEUP:
Pos = Pos - 1;
m_scrollWeights.SetScrollPos(Pos);
break;
case SB_LINEDOWN:
Pos = Pos + 1;
m_scrollWeights.SetScrollPos(Pos);
break;
case SB_THUMBPOSITION:
m_scrollWeights.SetScrollPos(nPos);
break;
case SB_THUMBTRACK:
m_scrollWeights.SetScrollPos(nPos);
break;
}
UpdateText();
UpdateEditBoxes();
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
.
If the value in the edit box is outside the range and I click on the scrollbar I get a "Debug Assertion Failed" message (File: wincore.cpp Line: 3102) and the prog bombs.
This occurs during the UpdateData() function. Removing UpdateData(); at the beginning solves the problem but I lose the data
I have tried using SetFocus at the beginning of OnVScroll to force it to check whether it is range but this does not work.
Help!
DAN B
|
|
|
|
|
First up let me admit to my dirty little secret. I am a lazy bastard and use DDX to move data to and from my screen fields and their associated member variables.
I have two ComboBoxes, when I make a selection in the first I want to fill the second with relevant data. Problem is I need to determine what has been selected in the first before I can fill the second.
I have used the following messages CBN_CLOSEUP, CBN_EDITCHANGE, CBN_SELENDOK and CBN_SELCHANGE. With each one, when I enter the function and call UpdateData(TRUE) the ComboBoxes member variable remains empty.
Should I be using another message I have yet to find or should I use some member function of CComboBox to achieve this?
PS. Tomasz how do you always have the relevant Knowledge Base article ready to quote. Have you commited them to memory or do you just have a search before posting your responses?
I have only used the knowledge base articles to fix operating system and network problems in the past. Didn't know there was so many development related answers there.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
You need to use CComboBox::GetCurSel() in the CBN_SELCHANGE Message.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Looks like I would actually need the follow code to do it.
CString strRslt;
m_cCombo.GetLBText(m_cCombo.GetCurSel(), strRslt);
Though I was hoping to get a message I could use that would allow me to stick with my lazy ways and use DDX.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Y prefer don't work with DDX, because I feel that I don't have the control over my source.
I only prefer to use the basic of DDX (for example to get pointers to the controls, etc). I prefer to write a little more.
Did You try with UpdateData() in the OnSelChange Message?
Best Regards!!!
Carlos Antollini.
|
|
|
|
|
Yes I did, it still didn't work, may have to ditch DDX after all.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Use DDX to associate CComboBox variables with dialog controls, but give up on calling UpdateData just for reloading combo.
Assuming that the combobox is dropdown list (users can only select values from the list, no freestyle typing possible), you should handle CBN_SELENDOK. In the handler, use GetCurSel to get the index of the selected item. This index should be all you need to refill another combo. You should call m_otherCombo.ResetContent() and add new items depending on the selection in m_firstCombo.
I'm not sure about combobox with the possiblity of direct text typing. You should probably wait until combo looses the focus - after all, you don't know if typed letter ends the word or is somewhere in the middle.
PS. Tomasz how do you always have the relevant Knowledge Base article ready to quote. Have you commited them to memory or do you just have a search before posting your responses?
ROTFL Sure, I've loaded them all using (very) lossy compression scheme.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz
I am not calling UpdateData() to load data into the second ComboBox only to determine what was selected in the first ComboBox.
ComboBoxes are CBS_DROPDOWN not CBS_DROPDOWNLIST as I am using Chris Maunder's Auto Completion ComboBox and it needs to allow typing in the EditBox.
In the CBN_SELENDOK of m_cCombo1 I call UpdateData(), m_cCombo2.ResetContent(), then check m_strCombo1 for selected value to determine what to put into second ComboBox and use m_cCombo2.AddString() to add the data to second ComboBox.
Think the answer maybe to use m_cCombo1.GetLBText(m_cCombo1.GetCurSel(), strRslt); Will try it out in the morning, 2:45 AM better get to bed.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
How to slove it ?
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Hello.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Thank you !
|
|
|
|
|
>>>
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
<<<
Are you by any chance explicitly adding any C/C++ standard libraries (C Run-Time Library or Standard C++ Library) to your link settings?
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I write an app that record single keystrocke and can lately retrieve and send this keystrocke on another computer.
I need also to retrieve its name (ex: "home" for scancode 71)
Even I searched a lot about this I'm still not sure how to store this keystrocke in a file to avoid international issue.
Recording Wparam and Lparam (wm_keydown) seem interesting while I can latetely retrieve the name of the key on user computer in his hown language with:
GetKeyNameText(pMsg->lParam,lpString,4);
and retrieve the scancode with MapVirtualKey( pMsg->wParam,0);
1-will this work ?
2-are the virtual key the same on each computer or should I directly store the scancode. (and so how to retrieve the name?)
I'm somewhat lost while there is so much ways to code a key.
Thanks
|
|
|
|
|
Hi,
Is it possible to make an ActiveX-control draw itself to a memory DC rather than to the current DC?
What I would like to do is to extract a single frame from an animation (avi, mpeg, ...) rendered by the windows media player ActiveX control, and get the bitmap bits from it without having to actually draw the frame on screen.
Do I maybe have to use a raw multimedia API and not use the ActiveX at all?
I glanced through the media player SDK v7.0, but it seems to be focusing on how to manipulate skins rater than content.
Can I trick it into drawing itself into memory?
/Niklas
|
|
|
|
|
How can I prevent the size of the checkboxes in a CListCtrl to be dependent on the size of the titlebar?
Check out these two shots to see exactly what I mean:
http://hjem.sol.no/clanoz/test/test_box18.jpg
http://hjem.sol.no/clanoz/test/test_box28.jpg
(The default size is 18)
Sprudling
|
|
|
|
|
The COMCTL32 implementation of checkboxes uses item state images. Basically, you can mimic this behavior by setting your own state image list with CListCtrl::SetImageList and handling WM_LBUTTONDOWN to flip checkmarks. As a bonus, your app will run on plain Win95 without any COMCTL32 updates coming from IE, Office or other MS products.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Could you please be a little more specific?
I'm trying to learn MFC, and this is the first CListCtrl i've ever created :]
Sprudling
|
|
|
|