|
NICE POST! [twothumbsup]
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
Where do i start when figuring out an error LNK2019: unresolved external symbol ?
I defined a function that returns a map
std::map<int, const="" char="" *=""> getMyMap
Whenever i try to call this function, getMyMap, i get the error.
|
|
|
|
|
LCI wrote: Where do i start when figuring out an error LNK2019: unresolved external symbol ? MSDN...?
It seems that the definition of getMyMap can't be found, if it's in another file make sure that you are linking with it.
|
|
|
|
|
It is all in the same class..
The definition was made in the .h file and the function is in the .cpp and it is also being called from there...
|
|
|
|
|
Found the problem.. it was my fault.
The defintion in the .cpp was without the class identifier.
Silly me...
Sorry
|
|
|
|
|
well... don't know what to say
|
|
|
|
|
Newbie question here. I have a bunch of text that I want to write both to the stdout and to a logfile using fprintf. Currently, I'm using the primitive method of just printing out everything twice, once to the stdout and once to the logfile. I thought about an elegant way of doing this, and the best I could come up with is to overload fprintf so it'll take two FILE* arguments, like fprintf(stdout, logfile "text %d", x, ...) etc. While trying to overload fprintf, however, I ran into difficulties since it takes a variable argument list and the overloading seems to be a lot more complicated. I played around with va_list, va_arg and such but ended up getting nowhere.
Is there an easy way of doing this, or can anyone offer some assistance in coding this up?
Thanks a lot in advance.
|
|
|
|
|
look at vfprintf(...) it takes a va_list
|
|
|
|
|
Have you considered:
void MyPrintf( const char *pFormat, ... )
{
va_list marker;
va_start(marker, pFormat);
vprintf(pFormat, marker);
vfprintf(stderr, pFormat, marker);
va_end(marker);
}
void main( void )
{
MyPrintf("%s\n", "Hello World");
MyPrintf("%d\n", 123);
}
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Is there any way to get a signal from the PC to my application when a USB device is added or removed from the PC. I have a USB chip (CP2102 from Silicon Laboratories), and I am currently polling every second and looking to see if it is still in the registry or not.
There must be any easier way to detect a USB connection or disconnection in C or C++. Is there anyway to ask Windows to send me a message or an event?
|
|
|
|
|
1 - RegisterDeviceNotification
2 - you can register a notification callback on changes to registry keys
earl
|
|
|
|
|
Thank you for pointing me in the right direction. I will try that tonight.
|
|
|
|
|
Hi fellows
In my app I have a treeview with some nodes. I want to select one of them and it will be highlighted. The problem is that I don`t get highlighted neither selected. This is my code to select a node:
[Code]
case WM_NOTIFY:
{
LPNMHDR notifyMessageStruct = (LPNMHDR)lParam;
if(notifyMessageStruct->hwndFrom == treeViewHwnd)
{
if(notifyMessageStruct->code == NM_CLICK)
{
nodeSelected = (HTREEITEM)SendDlgItemMessage(hwnd, IDC_TREE1, TVM_GETNEXTITEM, TVGN_CARET, (LPARAM)nodeSelected);
if(nodeSelected == NULL)MessageBox(NULL, "", "", MB_OK);
TreeView_EnsureVisible(hwnd, nodeSelected);
SendDlgItemMessage(hwnd, IDC_TREE1, TVM_SELECTITEM, TVGN_CARET, (LPARAM)nodeSelected);
SendDlgItemMessage(hwnd, IDC_TREE1, TVM_SELECTITEM, TVGN_DROPHILITE, 0);
}
}
break;
}
[/Code]
My code to create the treeview:
[Code]
treeViewHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_TRACKSELECT|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 400, myRect.bottom, hwnd, (HMENU)IDC_TREE1, hCurrentInstance, NULL);
[/Code]
Someone can helps? Thanks again
|
|
|
|
|
Not really sure what you are trying to do there. But maybe the tree doesn't have the focus and that's why you are not seeing the selection.
Add this TVS_SHOWSELALWAYS to the flags when you are creating the tree to see if that helps.
AliR.
Visual C++ MVP
|
|
|
|
|
I've been apointed to provide support for an old project which exports some data in xml files and then posts them on some web server. The problem is that the person that worked with this project before me does not check the xml data for chars like '<','>','&' and so forth.
The ideea is that instead of goint trough all the project and finding out where those xml's are created, i want to check them right before they get posted (which thankfuly is done by a single method).
Is there another way of finding '<' and '>' chars that are part of a node data without searching that file char by char?
|
|
|
|
|
|
I am attempting to play a sound when a button is clicked. I am using Microsoft Visual Studio .NET 2003 and to create my project I clicked File->New->Project, chose Visual C++ Projects and then Windows Forms Application (.NET). I then added a button to the form and in the click event I put the following code
PlaySound(_T("C:\\Windows\\Media\\chime.wav"), NULL, SND_LOOP);
I also included at the top of the file windows.h.
The errors that I receive are
error C2065: 'SND_LOOP' : undeclared identifier
error C3861: 'PlaySound': identifier not found, even with argument-dependent lookup
I would appreciate any help.
Thanks in advance
Keith
|
|
|
|
|
You created a managed application and PlaySound is an unmanaged function.
See this for help
CodeProject search[^]
AliR.
Visual C++ MVP
|
|
|
|
|
Did you include Mmsystem.h
whitesky
|
|
|
|
|
Hi, guys,
is there a way to intercept mouse clicks or keystrokes when an application runs in the background (a window does not have a focus) without using global Win32 hooks?
Thanks a lot.
|
|
|
|
|
Write a Keyboard Filter Driver
Write a Mouse Driver Filter
I've seen better runs in my shorts! - Patches O'Houlihan
|
|
|
|
|
I have not thought of the drivers. Thanks a lot.
|
|
|
|
|
I have 16 project that I only have the source code for that I would like to put into a Solution. I have been able to create a solution with all the 16 project directories, but when I view this in the Solution Config it only show the Project for which the Solution was create. Thus I can't compile and run each of the 16 project by them selves.
Kind of looks like this:
Solution A
StartServer
.C/.Cpp/.h
ShutdownServer
.C/.Cpp/.h
.
.
.
RunReport
.C/.Cpp/.h
Directory file structure is:
c:\Solution A\
c:\Solution A\StartServer\
c:\Solution A\ShutdownServer\
...
c:\Solution A\RunReport
Config file only shows Solution A thus it compile all 16 everytime...
I should be able to select on of the projects and compile/run it.
Any help would be much appriciated.
Jim
|
|
|
|
|
To do this you either have to right click on the project in the Solution Explorer window and select Project Only/Build Only... from the menu
Or you can select the project you want to build as the startup project, and under the build menu select the second set of build commands, the ones that have the project name in the menu item.
Selecting Build Solution (Ctrl+B) will build the entire solution which is all the project.
Also check the dependency of the projects to make sure they are correct. (Menu Project/Project Dependencies.
AliR.
Visual C++ MVP
|
|
|
|
|
I'm trying to load a disk file into memory and the program crashes when it tries to exit. As far as I can tell the file never got loaded. The compiler dosen't catch the error, but the debugger did point to this part of ios.cpp when it crashed, the line has a smilie next to it:
<br />
ios_base::~ios_base()<br />
{
if (0 < _Stdstr && 0 < --stdopens[_Stdstr]):mad:<br />
return;<br />
_Tidy();<br />
_DELETE_CRT(_Ploc);<br />
}
My specification file code:
#include "DnD_Common_Defs.h"<br />
#include "windows.h"<br />
#include <iostream><br />
#include <string><br />
#include <fstream><br />
<br />
using namespace std;<br />
<br />
class DataLoading<br />
{<br />
public:<br />
DataLoading();
RaceDataType ReturnRaceData(int RaceToReturn);<br />
protected:<br />
bool LoadUpRaceData(string FileName);
private:<br />
int NumBaseRaces;<br />
ifstream inData;
RaceDataType BaseRaces[6]; <br />
};
Relevant parts of implementation file code:
#include <iostream><br />
#include <fstream><br />
#include <string><br />
#include <cctype><br />
#include "Data_Loading_Class.h"<br />
#include "DnD_Common_Defs.h"<br />
<br />
using namespace std;<br />
<br />
DataLoading::DataLoading()<br />
{<br />
bool LoadedSuccessfully = false;<br />
const string RaceDataFileName = "RaceData.dat";<br />
NumBaseRaces = 7; <br />
<br />
LoadedSuccessfully = LoadUpRaceData(RaceDataFileName);<br />
}<br />
bool DataLoading::LoadUpRaceData(string FileName)<br />
{<br />
bool NoError = true;<br />
inData.open(FileName.c_str());
<br />
for(int i=-1; i<(NumBaseRaces-1); i++)<br />
{<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].RaceName;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.STRadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.DEXadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.CONadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.INTadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.WISadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.CHAadj;<br />
}<br />
if(inData)<br />
NoError = true;<br />
else<br />
NoError = false;<br />
inData.close();
<br />
return NoError;<br />
}
Thanks in advance.
-- modified at 14:48 Tuesday 18th July, 2006
|
|
|
|