|
did you try _findfirst() and _findnext() ?
|
|
|
|
|
Hello, I have an SDI application (MFC). I need to have an array of double numbers that can be sorted.I tried to use Array class from System namespace(.Net framework class) in one of my MFC classes but when I add
using namespace System;
to the begining of header file of my MFC class I get lots of error messages first one tells :
'System': a namespace with this name does not exist
to add a variable of class Array(System) to my MFC class, I wrote
array<double>^ m_dFrequencies
Can someone please give me a little help with that?
Thank you.
|
|
|
|
|
MFC is native C++.
System:: , and things such as array<>^ is C++/CLI (the Microsoft C++ extension for the .NET framework).
you're confusing/mixing both. don't.
do you want to code for .NET, or with MFC ?
|
|
|
|
|
thanks toxcct for reply,
My application which is pretty big and has about 20 classes is completely written using MFC but in my application I need an array with double type members whose members can be sorted. In all classes that are availabe under MFC such functionality dose not exist. Even sort capability dose not exist in "vector" and "queue". Array(System) has sort capability. I want to introduce just one member of type Array(System) to one of my MFC classes, so I'll be able to use sort functionality. How?
Thanks again.
|
|
|
|
|
Electronic75 wrote: Even sort capability dose not exist in "vector" and "queue
because you've got to learn about STL.
use std::vector<double> for your storage, and std::sort(vec1.begin(), vec1.end()) to sort it (with vec1 being an instance of the vector presented here.
to use those, you'll need to #include <vector> and <algorithm>
|
|
|
|
|
Thanks alot I'll try it.
|
|
|
|
|
Hi all. I've taken the liberty in "dissecting" some code so i can understand it better. However, im having a hell of a time trying to figure out how to convert it from C to C++ .
My error is this:
<br />
error C2664: 'recvfrom' : cannot convert parameter 6 from 'unsigned int *' to 'int *'<br />
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast<br />
Error executing cl.exe<br />
The offending code is as follows:
<br />
if ((respStringLen = recvfrom(sock, echoBuffer, ECHOMAX, 0, (struct sockaddr *) &fromAddr, <br />
&fromSize)) != echoStringLen)<br />
DieWithError("recvfrom() failed");<br />
<br />
if (echoServAddr.sin_addr.s_addr != fromAddr.sin_addr.s_addr){<br />
fprintf(stderr,"Error: received a packet from unknown source.\n");<br />
exit(1);<br />
}<br />
Im hoping i dont have to change too much, googling around i see others with the same problem but no solution. Any suggestions would be greatly appreciated. Thanx in advance!
|
|
|
|
|
Either change the definition of the fromSize variable from unsigned int to int, or change &fromSize to one of "(int*) &fromSize", "static_cast<int*>(&fromSize)", or "reinterpret_cast<int*>(&fromSize)" (depending on what you're trying to accomplish).
|
|
|
|
|
you're providing the culprit line of code and the error (and that's good already), but not enough. I'd like to know what is the exact synopsys of the function recvfrom() and the exact declaration of the variable fromSize .
anyway, the code you're showing is not C++ at all. you're certainly porting it into a more recent compiler, thus the error
|
|
|
|
|
The error is telling you what's wrong. The function takes an int* parameter, but you're passing an unsigned* instead. Change fromSize to an int .
|
|
|
|
|
Is it possible to copy a dialog resource in one workspace and add it to the resources in another workspace?
Thanks in advance.
John P.
|
|
|
|
|
open one of the two workspaces, and the resource file of the other workspace. the drag n' drop the dialog from one to the other.
if that doesn't work, open the doalog template, select all the controls on it (Ctrl+A should do) and paste on an empty, freshly created dialog of the resource file to edit.
save, close.
|
|
|
|
|
Thanks, toxcct --- I'll give it a try.
John P.
|
|
|
|
|
Neither of those approaches worked. Anything else you can think of? I tried copying all the .aps/.clw/.ncb/.opt/.plg/.rc files over to an older version and that didn't help either. Right now, I guess I'll just have to re-create the dialog into the version now running.
Thanks for your response.
John P.
|
|
|
|
|
Try opening the old .rc in text mode, finding the dialog in question and copy / paste it into the new .rc (also open in text mode). You'll need to add any control IDs that exist in the dialog in question to the resource.h.
jparken wrote: aps/.clw/.ncb/.opt/.plg
These are internal work files (class wizard, resource editor, build output, intellisense, ...) created on the fly by the IDE. They should never be copied when moving things between workspaces / solutions.
Judy
|
|
|
|
|
Thanks, Judy. I'll try it your way.
JudyL_FL wrote: These are internal work files (class wizard, resource editor, build output, intellisense, ...) created on the fly by the IDE. They should never be copied when moving things between workspaces / solutions.
I was grasping at straws and hoping --- thanks for the info.
John P.
|
|
|
|
|
Hi. I hope you were successful. I have a problem while trying to insert a resource for the dialog. Below is the code i am trying to use to create a dialog: After i insert the resource and create a new class for the dialog, it cant find the Script1.rc which has the dialog ID. If you can help me i'm really stuck:
Below is my code:
#include <afxwin.h>
#include "resource.h"
#include "newdialog.h" //my new dialog class
class MFC_Tutorial_Window :public CFrameWnd
{
public:
MFC_Tutorial_Window()
{
Create(NULL,"MFC Tutorial Part 5 CoderSource Dialog");
}
void OnClickDialogNew();
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP( MFC_Tutorial_Window, CFrameWnd)
ON_COMMAND(ID_MYDIALOG,OnClickDialogNew)
END_MESSAGE_MAP()
void MFC_Tutorial_Window::OnClickDialogNew()
{
NewDialog dlg;
dlg.DoModal();
}
class MyApp :public CWinApp
{
MFC_Tutorial_Window *wnd;
public:
BOOL InitInstance()
{
wnd = new MFC_Tutorial_Window();
m_pMainWnd = wnd;
m_pMainWnd->ShowWindow(1);
return 1;
}
};
MyApp theApp;
TreeS
|
|
|
|
|
With the new time_t what is the optimum way to format it into a string? I’ll guess that %lld would work, but I can not find any clear recommendations.
time_t myTime;<br />
time(&myTime);<br />
sprintf("This is my Time %lld .", myTime)
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
The MS CRT supports the I64 modifier in the format string to indicate a 64-bit variable: %I64d
|
|
|
|
|
I thought lld was the same as I64d.
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
MS must have added the ll modifier recently, in VC6 you have to use I64
|
|
|
|
|
I would suggest:
- In a global header:
#ifndef _WIN64
#define _USE_32BIT_TIME_T
#endif
This makes time_t (more) dependent on the target OS being 32bit or 64bit.
I consider this better than being (mainly) dependent on the compiler being VS6 or VS2005.
This should allow you to use %Id for printf with time_t, but ...
- Use either __time32_t or __time64_t (and related functions) explicitly.
Provide interfaces to handle both __time32_t and __time64_t.
If anyone will ever need to link to your API they will thank you.
If you need to link to someone else's time_t based API (compiled w/ VS6) you will understand.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hello all,
I need to be able to use a bridge to one machine that I'm making, I'd like to receive support from the guys in the company that made that machine, but it seems impossible.
I'm a little bit lucky, because I have a TLB file which I can import inside the C++ application that I'm developing.
In one header file I've just added: AInterfaces::CTPCallbackPtr m_ptrA; And in one function of the cpp file:
HRESULT hr = 0;<br />
hr = m_ptrA.CreateInstance("{99e84b23-58bb-11cf-b26c-00aa00b5c372}");<br />
if (hr == 0)<br />
{<br />
}
The return value is -2147221008, that indicates that the error is an OLE error, but here is when I get completely lost.
Could you give me an advice on that?
As always thank you in advance...
-- modified at 13:35 Thursday 19th April, 2007
|
|
|
|
|
Use the Error Lookup tool included with VC to find out what that error means: CoInitialize has not been called
|
|
|
|
|
I've noticed that, and I've called the CoInitialize(NULL); with the same result.
Which tool do you mean?
As always thank you in advance...
|
|
|
|