|
i face similar problem lik you but i solved that in little different way .
I created a Thread for Serial Port Processing and comunicate with main thread with help of events.
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
any chance you could post an example?
|
|
|
|
|
Can't you use SetTimer , KillTimer and OnTimer ? These work in millisecond units.
The tigress is here
|
|
|
|
|
Aren't windows timers only approximate? The original poster was stating 80ms - if this is a finger in the air value then SetTimer is good, else if it is exactly 80ms they need to wait, then this might cause issues?
From VC++ help :-
"Each time the specified interval (or time-out value) for a timer elapses, the system notifies the window associated with the timer. Because the accuracy of a timer depends on the system clock rate and how often the application retrieves messages from the message queue, the time-out value is only approximate. "
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
the problem:
have a SDI application , and need to create a "external" CWnd to the Mainframe (mainframe will recieve messages from the new window)
much like a tool window.
i want the new CWnd to be topmost and remain in the screen on top of all windows even if the application main window (mainframe) is not visible (i.e minimized)
the problem is that the new CWnd gets minimized with the application main window
any ideas?
"There is no sin in making an error - we all do, and that's how we learn. Sin lies in letting stand an error, once we discover it, without correcting it." Roger Wright
|
|
|
|
|
You can use SetWindowPos api with the External Window,you can read it documentation in MSDN
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I am doing a program for school, and I am to be tested for all situations. I believe that I have all of the otehr errors accounted for, but I have no idea how to handle the error when the user enters a "letter" into the console while they're playing the game(it's a simple guess the number game)... Any help would be greatly appreciated.
|
|
|
|
|
Hi There!
Simply use
IsDigit() function to check the valid charater is entered.
here a little code snippet
char ch;
ch=getch();
if(!isdigit(ch))
{
cout<<"please enter right character";
return;
}
else
{
........
carry on to program
........
}
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi,
How can I get the handle of the window of a process if I know the process id.
I need either the first window of a process or the topmost window or if there is a function that enumarates all the windows of a process that would also be good.
PS I don't want to enum all the windows on the desktop, that I know how to do but I am keeping it as a last resort option because that would consume a lot of resources unnecesarrily.
there must be a more efective way to do this like some kind of api that lets you enum only the windows from one process, no?
thank you in advance
please reply.
|
|
|
|
|
just get the window by enumerating them, then call GetWindowThreadProcessId() and compare it with your process ID you have. I hope this helps
gabby
|
|
|
|
|
How do I pass a CArray<struct, &struct> as a reference to a function?
I've tried the obvious &m_caArray
The function is defined as:
fn(CArray * caItem, int index)
....
I've tried defining the parameter as CObArray (and type cast the arguement) instead also but that didn't work either.
I keep getting the error:
"cannot convert parameter 1 from 'class CArray<struct,struct &> *' to 'class CObArray *'
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
I just tried these, works fine for me:
Using References
<br />
void TestFunction(CArray<CRect, CRect&>& rectArray)<br />
{<br />
int count = rectArray.GetSize();<br />
CString strCount;<br />
strCount.Format(_T("%d"), count);<br />
AfxMessageBox(strCount);<br />
}<br />
<br />
void CTestDlgDlg::OnFileOpen32773()<br />
{<br />
CArray<CRect, CRect&> rectArray;<br />
rectArray.Add(CRect(0,1,2,3));<br />
rectArray.Add(CRect(4,5,6,7));<br />
TestFunction(rectArray);<br />
}<br />
Using Pointers
<br />
void TestFunction(CArray<CRect, CRect&>* rectArray)<br />
{<br />
int count = rectArray->GetSize();<br />
CString strCount;<br />
strCount.Format(_T("%d"), count);<br />
AfxMessageBox(strCount);<br />
}<br />
<br />
void CTestDlgDlg::OnFileOpen32773()<br />
{<br />
CArray<CRect, CRect&> rectArray;<br />
rectArray.Add(CRect(0,1,2,3));<br />
rectArray.Add(CRect(4,5,6,7));<br />
TestFunction(&rectArray);<br />
}<br />
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Hicks,
Assuming that your CArray declaration is like this:
CArray <MyStruct, &MyStruct> arr;
Hope you've tried this:
YourFunction ( CArray <MyStruct, &MyStruct> &arrArg ) { }
If it works for you and you think it looks messy, try typedef-ing the "CArray <mystruct, &mystruct="">" part.
Clinton
|
|
|
|
|
I was trying to have a more generic function, where I could use it for more than just that one CArray. Thanks anyways
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
Try using a template...
template<typename T1, typename T2>
fn(CArray<T1, T2> &caItem, int index)
{
...
} This will let you use the function for any CArray type
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Can someone please explain to me all possible ways of establishing a network connection in user mode... other than using winsocks.
I've found this interesting diagram: http://www.ndis.com/papers/winpktfilter.htm[^]. It appears to me that the only other way of establishing a connection would be to create a Layered Service Provided dll ?? Am I wrong. I've also ran across this : http://www.microsoft.com/msj/0599/LayeredService/LayeredService.aspx[^]. It appears to me that LSP is used for filtering... but is it still possible for an LSP to establish a connection?
|
|
|
|
|
Anonymous wrote:
but is it still possible for an LSP to establish a connection?
No it Not possible to use LSP to establish connection.it do only work of filtering and actual connection is made by WINSOCK.dll alone.
actualy you can consider LSP as Winsock HOOK.
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
OK. That makes perfect sense.
I've read some more about this stuff and some people mention that its possible to call TDI (Transport Driver Interface) directly. How can this be done?
|
|
|
|
|
Look into DeviceIoControl
Alex Korchemniy
|
|
|
|
|
Hello
I found a bad bug in the TabedReBar Sample http://www.codeproject.com/docking/TabedReBar.asp . If the toolbar is floating, some buttons, which are related to the doc/view are desiabled(Like the Save Button). But if the toolbar is docked, they are enable again.
why?
is there any solution out there?
|
|
|
|
|
While using Visual C++.Net I keep getting error C1190 with the following code. Please Help!
// animals.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
_gc class Animal
{
public:
int legs;
void SetName(String *name)
{strName = strName->Copy(name);}
String* GetName() {return strName;}
private:
String *strName;
};
int_tmain()
{
//TODO: Please replace the sample code below with your own.
Animal *cat,*bird;
cat = new animal;
bird = new animal;
cat->SetName("Cat");
cat->legs = 4;
bird->SetName(Bird");
bird->legs = 2;
Console::WriteLine("Animal 1");
Console::Write("Name: ");
Console::WriteLine(cat->GetName()):
Console::Write("Legs: ");
Console::WriteLine(cat->legs);
Console::WriteLine();
Console::WriteLine("Animal 2");
Console::Write ("Name: ");
Console::WriteLine(bird->GetName());
Console::Write("Legs: ");
Console::WriteLine(bird->legs);
Console::WriteLine();
return 0;
}
|
|
|
|
|
( seems some of your code is missing ... )
the Documentation for error C1190 says that you need to have
#using < mscorlib.dll>
in your code somewhere, I don't know where, because I'm not familiar with Managed C++.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
For example i got next architecture:
class BaseClass
{
virtual void Method1();
virtual void Method2();
};
class FuncClassOne: public BaseClass
{
void Method1();
void Method2();
};
class FuncClassTwo: public BaseClass
{
void Method1();
void Method2();
};
class Grup
{
BaseClass** m_ppObjects;
void CallAllMethods();
void Add(BaseClass* pBaseClass);
BaseClass* GetObject(long ObjectID);
};
So, i want to save this architecture and place everything in COM;
Let me try to explaint what i need (I imagine ):
IGrupPtr group(CLSID_Grup);
for(int i = 0;i<10;i++)
{
IFuncClassOnePtr p(CLSID_FuncClassOne);
group->Add(p);
}
for(int i = 0;i<10;i++)
{
IFuncClassTwoPtr p(CLSID_FuncClassTwo);
group->Add(p);
}
group->CallAllMethods();
BaseClass* pClass = group->GetObject(7);
So how can i make frome every class COM Interface?
Is it possible? Or i need to choose another way???
|
|
|
|
|
Their is quite alot of things that go into making a COM object, however to set you in the right direction:
1. your 2 interfaces I am assuming will be FuncClassOne and FuncClassTwo. To do that you need to define them as such (BTW all COM interfaces derive from IUnknown)
interface FuncClassOne : IUnknown
{
virtual void __stdcall Method1() = 0;
virtual void __stdcall Method2() = 0;
}
interface FuncClassTwo : IUnknown
{
virtual void __stdcall fc2_Method1() = 0;
virtual void __stdcall fc2_Method2() = 0;
}
2. Now you will need your COM object, containing your interfaces and the implementations.
class FuncClass : public FuncClassOne,
public FuncClassTwo
{
public:
virtual HRESULT __stdcall QueryInterface(REFIID iid, void** ppv);
virtual ULONG __stdcall AddRef();
virtual ULONG __stdcall Release();
virtual void __stdcall Method1();
virtual void __stdcall Method2();
virtual void __stdcall fc2_Method1();
virtual void __stdcall fc2_Method2();
FuncClass();
~FuncClass();
private:
long m_cRef;
};
3. Now you need to implement your COM functions
This was really just so you could see the COM implementation in C++ for what you were asking (At least I hope it was what you were asking). You really should look on MSDN for what is required to implement the COM functions and how to create CLSIDs and register your component. Unfortunately the topic is just too large to be answered fully, on this post. I hope I at least got you going in the right direction and knowing what to look for now.
|
|
|
|
|
Thank you for participating i tried to do something like you show me:
So I made an ATL Project, and in the midle file i wrote next thing:
[
object,
uuid(BFBF8B9C-64BF-42bc-82D5-8564B637012B),
dual,
nonextensible,
helpstring("IAbstractGeoObject Interface"),
pointer_default(unique)
]
interface IAbstractGeoObject : IDispatch
{
[id(1), helpstring("method Draw")] virtual HRESULT Draw() = 0;
}
[
object,
uuid(16578C15-F715-4A3A-94E7-70C1387A53B7),
dual,
nonextensible,
helpstring("IGeoObject Interface"),
pointer_default(unique)
]
interface IGeoObject : IAbstractGeoObject{
[id(1), helpstring("method Draw")] HRESULT Draw(void);
};
But it doesn't want to compile it... It shows next error message:
"Expecting a type specification near "virtual""...
So i'm in the dead end...
|
|
|
|