|
When I include the parent header file it gives the error that says:
"childclass" not declared...
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
Hi,
Please post the code snippet and state in which line are you getting the compile error.
Best Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
<br />
#include "Form2.h"<br />
Form2 ^f=gcnew Form2;<br />
f->ShowDialog();<br />
<br />
#include "Form1.h"<br />
<br />
Error: <br />
syntax error : identifier 'Form2'<br />
error C2065: 'f' : undeclared identifier<br />
error C2065: 'Form2' : undeclared identifier<br />
error C2227: left of '->ShowDialog' must point to class/struct/union/generic type<br />
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
(Hopefully this is the right forum - This is all done in VC++.NET)
Sprinkled Throughout the various project I have are some where, if the design mode window is part of startup, it takes a rather long time for the project to be loaded. Similarly, if already opened, opening the design-mode window take a rather long time. I believe I know why it's happening, but I don't know how to stop it - and it can be very annoying.
Why I know:
1) Projects with database's attached (::SqlClient) are the worst offender - but not all of them.
2) A digital clock custom control I made, when put into a project, was actually ticking merrily away in the design mode window
I conclude that the horrid delay may be establishing (and timing out) of dBase connections.
Does anyone know how to disable this 'live' state of a project that, in my philosophy at least, should not be running?
For now, it's a catch-22: I can re-arrange the code and the items aren't intialized at this point - but that also means they're not on the designer window and that sort of defeats the whole purpose - which is having an open designer window.
Thanks, in advance,
Balboos
Notes: VS2003, VS2005, VS2008 .
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to go away?" - Balboos HaGadol
|
|
|
|
|
led mike wrote: I can't be sure what that means but if you are talking about your custom control then yes. The designer interfaces include the ability to know during initialization if it is a designer instance. You can use that information to avoid doing any processing that you don't want the control to do in designer mode.
led mike
|
|
|
|
|
Now All I Have To Do Is Hunt This Down this Knowledge - from you comment, I gather it is not a setting.
Thanks for a direction.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to go away?" - Balboos HaGadol
|
|
|
|
|
Balboos wrote: Now All I Have To Do Is Hunt This Down this Knowledge
If by that you mean read the documentation then yes. If someone has told you can become an accomplished software developer without reading the documentation they told you wrong, don't believe them.
led mike
|
|
|
|
|
I know the intent of your comment, so I'll take it as well-meaning. My statement was rhetorical.
led mike wrote: If by that you mean read the documentation then yes
I am, in fact, one of those odd people who read the manuals when they buy new things.
led mike wrote: If someone has told you can become an accomplished software developer without reading the documentation they told you wrong, don't believe them
As for development, I bootstrapped my way through all the coding method - learning assembler before C, for example. All of it from books, the occasional system help file, and copious sweat.
But -
MS loves to jerk around with users - moving things around, changing them, etc. There may well have been a setting to fix the problem somewhere (but certainly not in MS Help - aka "Idiots Guide To Chasing Their Own Tail").
There is another concept - and when used with appropriate discreation - equally valuable to that of looking-it-up: putting ones ego aside, admitting ignorance, and asking.
Learning to say "I don't know".
So - indeed - you're right in discouraging moochers and general brain-sucking by the lazy. But, just the same, we are (or should be) a gestalt community.
Balboos
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to go away?" - Balboos HaGadol
|
|
|
|
|
Balboos wrote: My statement was rhetorical.
hehe, i didn't get that at all. Text messaging doesn't always translate well eh?
Balboos wrote: MS Help - aka "Idiots Guide To Chasing Their Own Tail"
Yeah I gave up on that years ago. I always use Google to search MSDN by just putting MSDN as the first key word.
I don't remember the specifics so I couldn't tell you but it's part of the Designer library that contains what I referred to. So like System.Drawing.Design but I seem to remember there might be another namespace also containing Designer classes.
Anyway, I know it's there but I can't give you the specific location.
led mike
|
|
|
|
|
Thanks for a nudge in the rigth direction.
All those namespaces - it's easy to get distracted. Actually, that some of the fun of it: like looking up a word in a (paper) dictionary and then browsing a bit at the words around it. One of the losses of electronic equivalents (at least for now).
Today's my half-day: I can give the design namespace(s) a good spin. I blew much of yesterday addressing a minor failing in the automatic refactoring (if that's the correct term, snicker) when a class is renamed: to wit, I created a Windows.Forms project (as an executable) and renamed Form1 to a relevant name.* It sadly does not fix the references to the .resources files, manifesting itself as a runtime crash. Finally found the right option for changing the reference. Maybe VS10 will fix this.
If I get this to fix the design-time execution, I'll let you know the specifics. I can't be the only one suffering from this.
* the .exe can be referenced like a dll, but who want to work with namespace::Form1, anothernamespace::Form1, etc. Why do it this way, instead of a form class directly? much more rapid development. I can convert it to a real .dll if/when I have to.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to go away?" - Balboos HaGadol
|
|
|
|
|
Can anyone tell me how to find which specific processes are running on opened TCP ports??
As far as I sacnned the MSDN documentation, the information is found in GetExtendedTcpTable
and we have to import iphlpapi.dll for this..
Here is the snippet of my code:
class ProcessClass<br />
{<br />
public:<br />
[DllImport("iphlpapi.dll")]<br />
DWORD GetExtendedTcpTable(PVOID tcpTable, PDWORD tcpTableLength, BOOL sort, ULONG ipVersion, TCP_TABLE_CLASS tcpTableType, ULONG reserved);<br />
MIB_TCPROW_OWNER_PID tcpTable[2000];<br />
<br />
void GetProcesses();<br />
};<br />
<br />
void ProcessClass ::GetProcesses()<br />
{<br />
DWORD size = 2000;<br />
GetExtendedTcpTable(&tcpTable, &size, FALSE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0); <br />
}
But the problem is that I get an empty 'tcpTable'..
How to get the process ID's??
Som
|
|
|
|
|
Why are you using DllImport when you are developing in C++?
What OS and SP are you running on?
led mike
|
|
|
|
|
What's the return value from GetExtendedTcpTable?
You are incorrectly using the first two parameters in the call.
The structure pointed to should be a MIB_TCPTABLE_OWNER_PID struct,
inside of which should be an array of MIB_TCPROW_OWNER_PID structs.
You also have no idea if 2000 is enough bytes for the struct. You need to use the API
correctly to get the actual size you need and allocate the struct as an array of bytes.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all
Could anyone please let us know the C++ API (do not want Windows API) which will give the base address of the current stack ?
Thanks in advance
redindian
|
|
|
|
|
|
Server
<br />
Socket ^s....<br />
FileStream ^fs..<br />
array<byte>^data=gcnew array<byte>(4096);<br />
int len;<br />
do<br />
{<br />
len=fs->Read(data,0,4096);<br />
s->Send(data,0,len);<br />
}<br />
</byte></byte>
file Send but don't Complete i think socket send byte with Speed and data Replace with data!
|
|
|
|
|
javad_2005 wrote: file Send but don't Complete
Send to what?
Don't Complete means what?
javad_2005 wrote: i think socket send byte with Speed and data Replace with data!
I have no idea what that means but it sounds like something I would not believe.
led mike
|
|
|
|
|
None of the Socket::Send() overloads matches your code. Which one are you using?
What type of array is data?
Where's the loop logic code?
Is the socket blocking or non blocking?
You don't check the number of bytes sent? What if they all don't get sent in one Send() call?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
We are like a double decker Filet-o-Fish in this thread. Do they make one of those?
led mike
|
|
|
|
|
Server Code:
<br />
enum Command<br />
{<br />
NULL,<br />
Message,<br />
CreateFile,<br />
WriteFile,<br />
Close<br />
};<br />
<br />
Object ^ RawDeserialize(array<Byte> ^rawdatas, Type ^anytype ) <br />
{ <br />
int rawsize = Marshal::SizeOf(anytype ); <br />
if( rawsize > rawdatas->Length ) <br />
return nullptr; <br />
IntPtr buffer = Marshal::AllocHGlobal( rawsize ); <br />
Marshal::Copy( rawdatas, 0, buffer, rawsize ); <br />
Object ^retobj = Marshal::PtrToStructure( buffer, anytype ); <br />
Marshal::FreeHGlobal( buffer ); <br />
return retobj; <br />
} <br />
[StructLayout(LayoutKind::Sequential, Pack=1, CharSet=CharSet::Ansi)] <br />
ref struct TcpPacket<br />
{<br />
[MarshalAs(UnmanagedType::ByValArray,ArraySubType=UnmanagedType::LPWStr,SizeConst=4096)]<br />
array<Byte>^data; Command cmd; int Length; public:<br />
TcpPacket()<br />
{<br />
cmd=Command::NULL;<br />
data=gcnew array<Byte>(4096);<br />
}<br />
};<br />
ref struct ClientInfo<br />
{<br />
Socket ^socket;<br />
array<Byte> ^Buffer;<br />
};<br />
<br />
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)<br />
{<br />
Socket ^TcpSocket=gcnew Socket(AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp);<br />
IPEndPoint ^ipEndPoint=gcnew IPEndPoint(IPAddress::Any,5400);<br />
TcpSocket->Bind(ipEndPoint);<br />
TcpSocket->Listen(0);<br />
TcpSocket->BeginAccept(gcnew AsyncCallback(this,&Form1::OnAccept),TcpSocket);<br />
}<br />
<br />
void OnAccept(IAsyncResult ^ar)<br />
{<br />
ClientInfo ^info=gcnew ClientInfo;<br />
Socket ^socket=safe_cast<Socket ^>(ar->AsyncState);<br />
Socket ^SockAccept=socket->EndAccept(ar);<br />
TcpPacket ^Packet=gcnew TcpPacket; int PSize=Marshal::SizeOf(Packet);<br />
info->socket=SockAccept;<br />
info->Buffer=gcnew array<Byte>(PSize);<br />
SockAccept->BeginReceive(info->Buffer,0,PSize,SocketFlags::None,gcnew AsyncCallback(this,&Form1::OnReceive),info);<br />
}<br />
void OnReceive(IAsyncResult ^ar)<br />
{<br />
ClientInfo ^info=safe_cast<ClientInfo ^>(ar->AsyncState);<br />
info->socket->EndReceive(ar);<br />
<br />
TcpPacket ^Packet=gcnew TcpPacket; <br />
Type ^typeTcpPacket=Type::GetType(String::Format("{0}",Packet));<br />
Packet=(TcpPacket ^)RawDeserialize( info->Buffer,typeTcpPacket);<br />
ReleasePacket(Packet);<br />
int PSize=Marshal::SizeOf(Packet);<br />
info->Buffer=gcnew array<Byte>(PSize);<br />
info->socket->BeginReceive(info->Buffer,0,PSize,SocketFlags::None,gcnew AsyncCallback(this,&Form1::OnReceive),info);<br />
}<br />
FileStream ^file;<br />
void ReleasePacket(TcpPacket ^Packet)<br />
{<br />
switch(Packet->cmd)<br />
{<br />
case Command::CreateFile:<br />
{<br />
file=gcnew FileStream("c:\\2.jpg",FileMode::Create);<br />
break;<br />
}<br />
case Command::WriteFile:<br />
{<br />
file->Write(Packet->data,0,Packet->Length);<br />
break;<br />
}<br />
case Command::Close:<br />
{<br />
file->Close();<br />
MessageBox::Show("File Complete");<br />
break;<br />
}<br />
<br />
}<br />
}<br />
<br />
Client Source
<br />
array<Byte> ^ Serialize(Object ^Struct)<br />
{<br />
<br />
int len=Marshal::SizeOf(Struct);<br />
IntPtr ptr=Marshal::AllocHGlobal(len);<br />
array<Byte>^ rawdatas = gcnew array<Byte>(len);<br />
Marshal::StructureToPtr(Struct,ptr,false);<br />
Marshal::Copy( ptr, rawdatas, 0, len ); <br />
Marshal::FreeHGlobal( ptr ); <br />
return rawdatas; <br />
}<br />
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)<br />
{<br />
Socket ^TcpSocket=gcnew Socket(AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp);<br />
TcpSocket->BeginConnect(gcnew IPEndPoint(IPAddress::Parse("127.0.0.1"),5400),<br />
gcnew AsyncCallback(this,&Form1::OnConnect),TcpSocket);<br />
}<br />
void OnConnect(IAsyncResult ^ar)<br />
{<br />
Socket ^socket=safe_cast<Socket ^>(ar->AsyncState);<br />
socket->EndConnect(ar);<br />
FileStream ^file=gcnew FileStream("c:\\1.jpg",FileMode::Open);<br />
TcpPacket ^Packet=gcnew TcpPacket; <br />
array<Byte>^ Data=gcnew array<Byte>(Marshal::SizeOf(Packet));<br />
Packet->cmd=Command::CreateFile; <br />
Data=Serialize(Packet);<br />
socket->Send(Data,Data->Length,SocketFlags::None);<br />
int len;<br />
do<br />
{<br />
Packet->cmd=Command::WriteFile;<br />
len=file->Read(Packet->data,0,4096);<br />
Packet->Length=len;<br />
Data=Serialize(Packet);<br />
socket->Send(Data,Data->Length,SocketFlags::None);<br />
}while(len>0);<br />
<br />
Packet->cmd=Command::Close;<br />
Data=Serialize(Packet);<br />
socket->Send(Data,Data->Length,SocketFlags::None);<br />
}<br />
<br />
|
|
|
|
|
Hi, I'm attempting to create a collapsible property in the the PropertyGrid. I've got it to work properly, the only issue I'm having is the sub-properties in the collapsible section are all in bold. I've set their DefaultValueAttributes to be the same as their value, and still they are bold. Is there something different I have to do when they are collapsible? Below is the code for the collapsible section.
<br />
ref class PointF3D : public System::Object<br />
{<br />
protected:<br />
float x;<br />
float y;<br />
float z;<br />
<br />
public:<br />
<br />
<br />
PointF3D(float fx, float fy, float fz)<br />
{<br />
x = fx;<br />
y = fy;<br />
z = fz;<br />
}<br />
<br />
void FromString(System::String^ s);<br />
<br />
virtual System::String^ ToString() override;<br />
<br />
[System::ComponentModel::RefreshProperties(<br />
System::ComponentModel::RefreshProperties::Repaint), <br />
System::ComponentModel::DefaultValueAttribute(0)]<br />
property float Z {<br />
float get() { return z; }<br />
void set(float value) {<br />
z = value;<br />
}<br />
}<br />
<br />
[System::ComponentModel::RefreshProperties<br />
(System::ComponentModel::RefreshProperties::Repaint),<br />
System::ComponentModel::DefaultValue(0)]<br />
property float Y {<br />
float get() { return y; }<br />
void set(float value) {<br />
y = value;<br />
<br />
}<br />
}<br />
<br />
[System::ComponentModel::RefreshProperties(<br />
System::ComponentModel::RefreshProperties::Repaint),<br />
System::ComponentModel::DefaultValue(0)]<br />
property float X {<br />
float get() { return x; }<br />
void set(float value) {<br />
x = value;<br />
<br />
}<br />
}<br />
<br />
<br />
<br />
};
Thanks!
|
|
|
|
|
TheBerk wrote: Hi, I'm attempting to create a collapsible property in the the PropertyGrid.
Do you mean you are using System::ComponentModel::ExpandableObjectConverter? I don't see that anywhere in your post.
What version of .NET are you using?
led mike
|
|
|
|
|
Forgot to include that, I've used the ExpandableObjectConverter as a base class and inherited from it with:
[System::ComponentModel::TypeConverter(PointF3DConverterSystem::typeid)].
The new class just allows for the main line of the collapsible property to display the correct string.
|
|
|
|
|
TheBerk wrote: the sub-properties in the collapsible section are all in bold.
what specifically is in bold?
I just ran my app ( in XP Pro .NET 2.0) where I am using it and the editable values are all in bold. The property names are not in bold even for the ExpandableObject implementation. So it looks like all the other items in the PropertyGrid accept you can expand/collapse it.
led mike
|
|
|
|
|
Its not the property names, but the values that can be altered when the collapsible property is expanded. The header value for the collapsible property is not in bold, but its sub values are. Values are only suppose to be in bold when they are altered from their default values, but my values match the default and they still appear bold.
Thanks!
|
|
|
|
|