|
I'm sorry...what?
What do you mean you "press ok"? Runtime? Design time?
I'm lost
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hehehe sorry i let you alone inside forest
Ok here i am to rescue u !
i use Microsoft Visual studio C++ 6.0 enviroment
i press right click on the Class and press Add member function
on the window it pop up i time
Type: double
Function declaration : Find(CString file , ....) and i have to press OK or cancel
|
|
|
|
|
Ohhh ok
I've never used the add function wizard but I just tried it on VS 2003 .NET.
I chose "Add/Add function.." for a class.
Selected a return type
typed a function name
for the parameter type, I typed "CArray<int, int&> &"
parameter name I typed MyIntArray
clicked the Add button to add the parameter
clicked Finish and the function was added to my class
I'm not sure how different that is from VC 6 (I bet David Crow knows )
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
double CAnaktisiDlg::FindDF(CString file , CArray < CString, CString& > &FArray)
is what i create (indetifier CArray error)
double CAnaktisiDlg::FindDF(CString file , CArray < CString, CString& > FArray)
same :/
according to you it had to be working fine
|
|
|
|
|
Works for me but I'm on a different VS version.
I also have included afxtempl.h in my projects, although I'm not sure if the wizard uses that...
You can always add the function by hand
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi, I cann't take my own IP address on Windows Server 2003.
This is the code i'm using, it works fine in Windows 2000 (Professional and Server) and Windows XP, but DOESN'T WORK IN Windows Server 2003.
I'm getting crazy, Why it doesn't work only in Windows 2003?
int iSockErr = 0;
HANDLE hnd = 0;
WORD wVersionRequested = MAKEWORD(2, 2);
WSADATA wsaData;
try
{
if ((iSockErr = WSAStartup(wVersionRequested, &wsaData)) != 0) { throw 1; }
DWORD dw;
GUID guid = SVCID_HOSTNAME;
struct AUX{
WSAQUERYSET qsRestrictions;
BYTE byte[500];
}aux;
memset(&aux.qsRestrictions, 0, sizeof(WSAQUERYSET));
aux.qsRestrictions.dwSize = sizeof(WSAQUERYSET);
aux.qsRestrictions.lpServiceClassId = &guid;
if (WSALookupServiceBegin(&aux.qsRestrictions, LUP_RETURN_ADDR, &hnd)) { throw 2; }
dw = sizeof(aux);
memset(&aux, 0, sizeof(aux));
aux.qsRestrictions.dwSize = sizeof(WSAQUERYSET);
while ( !WSALookupServiceNext(hnd, LUP_RETURN_ADDR, &dw, &aux.qsRestrictions) )
{
ptyIP->d0 = aux.qsRestrictions.lpcsaBuffer[0].RemoteAddr.lpSockaddr->sa_data[2];
ptyIP->d1 = aux.qsRestrictions.lpcsaBuffer[0].RemoteAddr.lpSockaddr->sa_data[3];
ptyIP->d2 = aux.qsRestrictions.lpcsaBuffer[0].RemoteAddr.lpSockaddr->sa_data[4];
ptyIP->d3 = aux.qsRestrictions.lpcsaBuffer[0].RemoteAddr.lpSockaddr->sa_data[5];
}
...
Thank you very much.
|
|
|
|
|
alejandrofuchs wrote: Why it doesn't work only in Windows 2003?
Why don't you tell us? What does WSAGetLastError() return?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks,
It returns 0, indicating there is no error, but no data is returned.
alejandrofuchs@yahoo.com
|
|
|
|
|
Thanks!
First, i'm sorry, someone else (joseaxy) was already signed in codeproject in this machine, so my later response had that name.
Second (again i'm sorry), i responded wrong, the rigth answer is: WSAGetLastError() returns 10110, WSALookupServiceNext is returning 0 the second time it is called.
alejandrofuchs@yahoo.com
|
|
|
|
|
alejandrofuchs wrote: WSAGetLastError() returns 10110...
Which resolves to WSA_E_NO_MORE .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
alejandrofuchs wrote: First, i'm sorry, someone else (joseaxy) was already signed in codeproject in this machine, so my later response had that name.
hmmm...split personality?
If you try getaddrinfo(), does that work on Server 2003?
Something like:
char szHostName[256];
if (0 == ::gethostname(szHostName, sizeof(szHostName)))
{
char* port = "80";
addrinfo aiHints;
addrinfo *aiList = NULL;
int retVal;
memset(&aiHints, 0, sizeof(aiHints));
aiHints.ai_family = AF_INET;
aiHints.ai_socktype = SOCK_STREAM;
aiHints.ai_protocol = IPPROTO_TCP;
if ((retVal = ::getaddrinfo(szHostName, port, &aiHints, &aiList)) == 0)
{
addrinfo *pAddrInfo = aiList;
while (pAddrInfo)
{
pAddrInfo = pAddrInfo->ai_next;
}
<code>::freeaddrinfo(aiList);
}
}
-- modified at 14:41 Friday 8th June, 2007
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Yes, this works. I will change my code.
I still have the doubt about why it doesn't work only on Windows 2003, but as this code works fine i prefer this new aproach.
Thank you to you all for your help!
PD. Only for curiosity , if somebody find out what's wrong on the original code under 2003, please write.
alejandrofuchs@yahoo.com
|
|
|
|
|
alejandrofuchs wrote: I still have the doubt about why it doesn't work only on Windows 2003
I couldn't find any reason it wouldn't work in the Platform SDK for Server 2003...it's a mystery
to me!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
p.s. Don't forget to call freeaddrinfo() - I left that out of the code sample.
Cheers
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
EDITED: I have since fixed the problem, instead of using "delete this" in ThreadPool::Release(), I now call "delete m_threadPool" from Main.cpp. Now, I don't know exactly why this works, but here's a possibility:
Link to discussion on RtlFreeHeap
I will cut down on the source code that's not required to shorten my post.
/////////////////////////////////////////////////////////
So far, I haven't done too too much work on this project, however, I do have a few problems already. One is that when running the program, I get heap corruption (Error Message: HEAP[Core.exe]: Invalid Address specified to RtlFreeHeap( 00340000, 00373798 )). The second is that CThreadLocalObject::GetData() will cause an access violation exception which is handled (probably within MFC), but it still worries me that I get this exception. I can't debug into it either, so it's likely something I'm doing that's causing a failure somewhere deep below. The code might be a bit long for most people to want to read. The source code is posted below. The line that actually fails is "delete this" in ThreadPool::Release(). On top of all this, if anyone has any design considerations that they might have to offer, I would be glad to hear them. This is the first time I've worked with any multithreading framework, so any tips to prevent future headaches are appreciated.
Thanks a lot to anyone that takes the time to read this through.
#include <afxwin.h>
#include <THInc.h>
class MainWindow : public CFrameWnd
{
public:
CButton start;
CButton end;
CEdit textbox;
ThreadPool* m_threadPool;
EventSource* m_source;
EventReceiver* m_receiver;
MainWindow()
{
Create(NULL, "MFC Window");
start.Create("Start", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(10,10,100,30), this, 1);
end.Create("End", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(10,40,100,60), this, 2);
textbox.Create(WS_VISIBLE|ES_READONLY|ES_LEFT|ES_MULTILINE|ES_AUTOVSCROLL, CRect(10,70,100,120), this, 3);
}
void ButtonStart();
void ButtonEnd();
void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
DECLARE_MESSAGE_MAP()
};
void MainWindow::ButtonStart()
{
m_threadPool = new ThreadPool();
m_source = new EventSource();
m_receiver = new EventReceiver(m_threadPool);
m_receiver->HookThreadPool(m_source);
}
void MainWindow::ButtonEnd()
{
if (m_threadPool)
{
m_receiver->ReleaseThreadPool(m_source);
m_threadPool->Release();
m_threadPool = 0;
}
}
void MainWindow::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == VK_ESCAPE)
MessageBox("Escape button pressed");
}
BEGIN_MESSAGE_MAP(MainWindow, CFrameWnd)
ON_BN_CLICKED(1, MainWindow::ButtonStart)
ON_BN_CLICKED(2, MainWindow::ButtonEnd)
ON_WM_KEYDOWN()
END_MESSAGE_MAP()
class Application : public CWinApp
{
public:
BOOL InitInstance()
{
m_pMainWnd = new MainWindow();
m_pMainWnd->ShowWindow(SW_SHOW);
return TRUE;
}
};
Application theApp;
#include "ThreadPool.h"
HANDLE ThreadPool::m_threadHandles[3];
map<int, WorkUnit*> ThreadPool::m_workQueue;
bool ThreadPool::m_terminate = false;
ThreadPool::ThreadPool()
{
InitThreads();
}
ThreadPool::~ThreadPool()
{
}
void ThreadPool::SignalTermination()
{
HANDLE termMutex = CreateMutex(NULL, false, "TerminateThreadPool");
WaitForSingleObject(termMutex, INFINITE);
m_terminate = true;
ReleaseMutex(termMutex);
}
void ThreadPool::Release()
{
WaitForMultipleObjects(3, m_threadHandles, true, INFINITE);
delete this;
}
void ThreadPool::InitThreads()
{
unsigned int threadID[3];
for (int i = 0; i < 3; i++)
{
int* index = new int(i);
m_threadHandles[i] = (HANDLE)_beginthreadex(0, 0, &ThreadPool::BeginThread, index, 0, &threadID[i]);
}
}
unsigned int ThreadPool::BeginThread(void* pArgs)
{
HANDLE hWQMutex = CreateMutex(NULL, false, "WorkQueue");
HANDLE termMutex = CreateMutex(NULL, false, "TerminateThreadPool");
while (true)
{
WaitForSingleObject(hWQMutex, INFINITE);
int key = -1;
WorkUnit* value = 0;
if (m_workQueue.size() > 0)
{
map<int, WorkUnit*>::iterator iter;
for (iter = m_workQueue.begin(); iter != m_workQueue.end(); iter++)
{
value = (*iter).second;
if (value->GetState() == WorkState_Queued)
{
key = (*iter).first;
value = (*iter).second;
value->SetState(WorkState_Active);
}
else
continue;
}
}
ReleaseMutex(hWQMutex);
WaitForSingleObject(termMutex, INFINITE);
if (m_terminate)
break;
ReleaseMutex(termMutex);
if (key == -1)
Sleep(1000);
}
m_threadHandles[*((int*)pArgs)] = 0;
delete pArgs;
return 0;
}
-- modified at 13:06 Friday 8th June, 2007
|
|
|
|
|
Hello,
When I try to create a new project w/ Visual Studio .NET 2003
I now keep getting a a Message Box that says (something like)
A critical error occurred, Automation object could not be created.
Does anyone know what this means?
--thanks
|
|
|
|
|
Do you have any plugins, extensions to VS, installed now or in the past?
...---... wrote: A critical error occurred, Automation object could not be created.
basically means it went to create a COM object and found it couldn't for some reason. The Dll it lives in could have been deleted or the GUID VS is using to id the object could be corrupted. You could poke arounf in the config files for VS but I'd recommend doing an uninstall/reinstall as you don't know what else might be messed up
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks for your help.
I also have installed Visual Studio C# Express.
Maybe I should uninstall the program.
|
|
|
|
|
Iam new to MFC.
I have a Dialog Bar having a text box attached to toolbar. When i try to change the value of that text box i get an error - something like unsupported action.
When i debugged i came to know that its showing error on UpdateData(TRUE)
MY code is
class A{
.
.
.
MyDlgBar obj;
obj.Value="xxxxxx";// value is a public variable
obj.UpdateValue();
.
.
.
}
********
void MyDlgBar::UpdateValue(){
.
.
SetDlgItemText(IDC_EDIT1,Value);
UpdateData(TRUE);
.
.
}
Whats the reason for this . . .
|
|
|
|
|
Hi,
check whether you created the dialogbar using Create() function.
MyDlgBar obj; I think the constuctor donot create the window.
Best Regards
Raj
|
|
|
|
|
The dialog bar is being displayed but the above said functionality is not working... (passing a value to the dialog bar)
Proud To Be an Indian
|
|
|
|
|
Hi,
What the MyDlgBar::DoDataExchange() does?
|
|
|
|
|
i dint change it . . .
it have the default code some
DDX_Text(pDX, IDC_EDIT1, m_strIndicator);
where
//{{AFX_DATA_INIT(CIndicator)
m_strIndicator = _T("hi");
//}}AFX_DATA_INIT
|
|
|
|
|
Hi,
I'm working on an application that is trying to emulate a DOS prompt utilizing a CEdit box. I have the data scrolling as the data fills the window, but every so often the data stops updating. I can still scroll the window up and down, but the data just doesn't show up anymore.
My question is whether there is a buffer size the window can handle? Is there a way to actually have it function like command prompt and automatically erase/delete the oldest info from the screen? (right now it shows everything from the start of the application and never erases anything)
Thanks in advance
|
|
|
|
|
NYTSX wrote: My question is whether there is a buffer size the window can handle?
I seem to recall it being 64KB.
NYTSX wrote: Is there a way to actually have it function like command prompt and automatically erase/delete the oldest info from the screen?
Yes. You could keep everything in a CString variable, which you trim accordingly.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|