|
Hi ,
I have a template class like
template<typename t="">
public ref class MyBaseclass.
I need to inherit this class on another one like.
public ref class Derivedclass:MybaseClass<string>.
Could you please let me know whats the syntax for doing like this ?Sorry I am new to VC++.
|
|
|
|
|
template<typename T>
ref class Base
{
public:
Base(T value) : _value(value) {}
T get_value() { return _value; }
private:
T _value;
};
ref class Derived : Base<String^>
{
public:
Derived(String^ value) : Base(value) {}
};
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
#pragma once
#undef UNICODE
#define WIN32_LEAN_AND_MEAN
#pragma comment (lib, "Ws2_32.lib")
#include "stdafx.h"
#include <Winsock2.h>
#include <Ws2tcpip.h>
#include "vcclr.h"
#include<string>
#include<iostream>
#include <windows.h>
#include <process.h>
#include <stdio.h>
#include <sstream>
#include <stdlib.h>
namespace trial {
using namespace std;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Threading;
using namespace System::Runtime::InteropServices;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
public:
~Form1()
{
if (components)
{
delete components;
}
}
public: System::Windows::Forms::Button^ baslat_button;
public:
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
}
#pragma endregion
public: void start1(void* pParams )
{
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
}
private: System::Void baslat_button_Click(System::Object^ sender, System::EventArgs^ e)
{
hEvent1 = CreateEvent( NULL, FALSE, TRUE, NULL );
hEvent2 = CreateEvent( NULL, FALSE, FALSE, NULL );
_beginthread(start1, 0, NULL );
}
};
}
im working on visual studio 2010 ultimate,
When i compile the code i have got an error "beginthread" line
Error 1 error C3867:
How can i fix this problem?
|
|
|
|
|
By following the advice in the error message, and use the address of start1 in your _beginthread() call thus:
_beginthread(&start1, 0, NULL );
|
|
|
|
|
Hi, dear all,
I have a C++ project created in VS2003, now I convert it to VS2008, after fix some compile errors and setting change, it compiles ok and can be started.
This project application is an EXE file, not DLL file.
When I create a dialog object and call dlg.doModal(), get afxwin1.inl ASSERT error in AfxGetResourceHandle().
But the project works fine in VS2003.
Can anybody tell me what causes this issue and how to fix it?
Thanks!
|
|
|
|
|
Without seeing the actual code and the specific details of the ASSERT it is not very likely that we can guess what is going wrong.
|
|
|
|
|
CEditDlg *m_editDlg = new CEditDlg(this,propComp,propComp->Getbitmap(), propComp->GetType(),pWnd);
m_editDlg->SetEditComp(propComp);
m_editDlg->DoModal();
Error happens when call DoModal(). I debug inside the codes and see the error occurs becuase afxCurrentResourceHandle is NULL.
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()
{ ASSERT(afxCurrentResourceHandle != NULL);
return afxCurrentResourceHandle; }
It seems the resouce doesn't attache to the project, right, how can I solve it?
|
|
|
|
|
Since this is your own dialog you need to review the constructor to ensure you are correctly instantiating from a base CDialog() [^] class.
|
|
|
|
|
I told you everything works fine in VS2003. Also in VS2008 Release mode.
Yes,my dialog inherits from Dialog class, and in instructor, I do something like the following:
CEditDlg::CEditDlg( System::Object * mainApp, NCGenericCompont* pCompont, UINT menuSel, CString type,CWnd* pParent /*=NULL*/)
: CDialog(CEditDlg::IDD, pParent)
The codes should have no problem, the problem should be it cannot locates the resource file, there are a lots of people ask this questions about this in internet, but seems cannot find answer.
|
|
|
|
|
Well it's always possible this is a bug that should be reported to Microsoft.
|
|
|
|
|
Hi, Please check whether ur object is created properly before u call the domodal().
If it is fine, keep the break point in the dialog class's "oninitdialog" function and move forward step by step.
I guess the issue would be in any of the controls u have used.
Thanks,
Arun P.
|
|
|
|
|
Hi all, I am working on class to wrapp unmanaged pointer. I am just confused, whether pinning of value struct is needed in C++/CLI, i.e. whether if I will not do it, it can cause some problems.
In C#, I am not able to fix structs:
Point pntA = new Point(10, 25);
Point pntB = new Point();
unsafe
{
fixed (Point* ptrA = &pntA, ptrB = &pntB)
{
ptrB->X = ptrA->X;
ptrB->Y = ptrA->Y;
}
}
but, I can simply use address-of operator:
Point pntA = new Point(10, 25);
Point pntB = new Point();
unsafe
{
Point* ptrA = &pntA, ptrB = &pntB;
ptrB->X = ptrA->X;
ptrB->Y = ptrA->Y;
}
What is confusing me is that pin_ptr lets me pin structures as well as use address-of operator:
generic <typename T> where T : value struct
T GetValueA(void* ptr)
{
T val = Activator::CreateInstance<T>();
pin_ptr<T> valPtr = &val;
memcpy(valPtr, ptr, sizeof(T));
return val;
}
generic <typename T> where T : value struct
T GetValueB(void* ptr)
{
T val = Activator::CreateInstance<T>();
memcpy(&val, ptr, sizeof(T));
return val;
}
My questions are:
Is pinning needed in C++/CLI functions to fix value struct
before using its pointer in unmanaged function?
Are value structs allocated in the unmanaged heap?
Thanks all,
Dusan
|
|
|
|
|
Hi,
I have created a checkbox using MFCRibbonCheckBox. Depending on certain conditions i want to disbale it.
But it does not have any property for disabling. Can anybody help me out?
thanx in advance
|
|
|
|
|
Hello everybody.
I'm doing a little project for my B.Sc degree, in which i need to retreive tcp parameters and proceess them.
I'm kinda new to all this socket proggraming and network progamming, can you help me with writing a proggram that gets the TCP parameters in c++?
thanks
|
|
|
|
|
Assuming you are doing this in Windows then you can start here[^].
The best things in life are not things.
|
|
|
|
|
Richard's suggestion is accurate, but if you'd like to see what your target program should look like, see Wireshark[^]. If you're allowed to use libraries for your programs, Wireshark is based on a library called WinPCap[^] (which you can pull into your code and query to capture different types of traffic).
|
|
|
|
|
He's doing a BSc and cannot even start to research his chosen subject!
The best things in life are not things.
|
|
|
|
|
Maybe he just needs a little push... 
|
|
|
|
|
Joking aside, I am constantly amazed at the number of people doing degrees who do not seem able to use the most basic bit of initiative to start investigating the subject they choose to do their dissertations on. How anyone can be doing a college/university course in computing and not know how to perform a simple Google search is quite worrying; how on earth are these people going to fare when working in the real world?
[edit]Yes, I know, this is not really the place for a rant.[/edit]
The best things in life are not things.
|
|
|
|
|
I do agree, quite surprising to see that many people ask questions without research... Maybe these are the people who never finish a degree or change major after a few courses.
|
|
|
|
|
A little help please.
Is there any reason why the following will not work in a managed C++/CLI project?
A vector of pairs of managed Strings.
cliext::vector<cliext::pair<System::String ^, System::String ^> > ^attributes;
When linking I receive the following error...
1>Linking...
1>Generating code
1>Finished generating code
1>gm_vcet_k010_dimension_exporter.obj : error LNK2020: unresolved token (060000EB) cliext.vector<cliext::pair<System::String ^,System::String ^> >::Clone
1>C:\Documents and Settings\zzmgd6\My Documents\nxopen\k010_vcet_dimension_reporter\Release\gm_vcet_k010_dimension_exporter.dll : fatal error LNK1120: 1 unresolved externals
Thanks for any help.
modified on Wednesday, July 20, 2011 9:27 PM
|
|
|
|
|
You don't need the ^ in front of attributes. Here's a working example:
#include "stdafx.h"
#include <cliext/vector>
#include <cliext/utility>
#include <cliext/algorithm>
using namespace System;
int main(array<System::String ^> ^args)
{
using namespace cliext;
vector<pair<System::String^, System::String^>> attributes;
attributes.push_back(make_pair(gcnew String("Background"), gcnew String("Red")));
attributes.push_back(make_pair(gcnew String("Visibility"), gcnew String("Collapsed")));
attributes.push_back(make_pair(gcnew String("Happy"), gcnew String("True")));
for_each(attributes.begin(), attributes.end(), [](pair<System::String^, System::String^> p){
Console::WriteLine(p.first + " = " + p.second );
});
return 0;
}
|
|
|
|
|
I developed Web Services program in WCF with VS 2008 C++/CLI on server side and deployed it. But I have no idea how to generate wsdl file. My template is Visual C++ CLR console application. So i can't see any wsdl file.
I need your advice! Thanks in advance.
Best Regards!
Joseph Hwang
|
|
|
|
|
Have you tried putting the service address in a browser and appending ?wsdl to the address?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
how to use crystal report in c++/clr?
is it possible to do so or i have to use other options?
i need to print some labels and a picture box, is it a good idea to use reporting or i should consider capturing the form screen and then print it.
|
|
|
|