|
When you are calling an ActiveX DLL in a VC++ app and you declare a pointer to the SAFEARRAY, how do you reference the actually array data that is being passed back in the function call.
|
|
|
|
|
Explain yourself better and I might be able to help.
|
|
|
|
|
Hi,
Got your email. So you are trying to access the raw array data in C++?
a couple of q's:
> CtGetDigitalOutput128 is being called by C++, not VB, right? (VB can't easily use raw array data.)
> What error/problem do you have when trying to do this, and where?
|
|
|
|
|
Howdy'
I need to resize a CButton according to the text I'm placing in it, when the button is created.
Is there a thing I can do that is easier than doing a DT_CALCRECT on the text(or something like that), and resizing the button to fit ?
Thanks.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
I want to interrupt:
ReadFile(((Messgeraete*)lparam)->h_com, &inbuffer1, 13, &nBytesRead1, NULL);
I've used ReadFile without timeout.
Interruption should be done from another Thread.
Does anybody no an order which kills the "ReadFile".
Thanks
Heiko
|
|
|
|
|
I solve this problem by reading a little bit of the file at a time ( usually 2K, 4K or 8K) then checking to see if I should try to read more. If your are going to use threads use a kill event as your check.
John
|
|
|
|
|
Sorry, for not mention it
I don't want to read from a File. I want to read two times 13bytes for com1;
the 13th ist an carriage return.
You say I should use a kill Event, but I don't know which Event I should take.
Can you give me an example.
Here is a part of my programcode:
h_com = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
...settings of dcbs and COMMTIMEOUTS
ReadFile(((Messgeraete*)lparam)->h_com, &inbuffer1, 13, &nBytesRead1, NULL);
ReadFile(((Messgeraete*)lparam)->h_com, &inbuffer2, 13, &nBytesRead2, NULL);
Now I need the command (which I want to use in my Thread) to kill the ReadFile
Thanks
Heiko
|
|
|
|
|
Thanks for the info, now that I see what you mean I am not sure how to do this.
John
|
|
|
|
|
Solution was to kill the whole thread which contains the command readfile
|
|
|
|
|
Use ReadFile asynchronously by defining overlapped structure.
Use GetOverlappedResult for waiting for reading completion or for your stop event.
Don't forget to use OpenFile with the flag FILE_FLAG_OVERLAPPED.
|
|
|
|
|
I created a control which is CWnd derived and nested it in an SDI application
with a CSplitterWnd derived class ( 2 columns, the Ctrl is in the left one, a CView is in the right one, no custom Paint operation ).
The Ctrl uses FillSolidRect via a MemoryDC an OnEraseBkgrnd() returns FALSE.
When I resize the ParentFrame, the Ctrl, the StatusBar and the Toolbar are extremely flickering.
I tried overriding CSplitterWnd::OnEraseBkgrnd() but it kept flickering, nontheless.
Has anyone an idea, what I can do about this issue?
Thanks
|
|
|
|
|
You should prevent window from being redrawn at the beginning of the sizing and at the end you should restart the redrawing...
take a look at msdn the article:
Tip 63: Preventing List Box from Redrawing (Refreshing)
it talks about WM_SETREDRAW...
hope this helps...
|
|
|
|
|
Overriding CSplitterWnd::OnEraseBkgrnd() should solve the problem.
It should look like this:
BOOL CSplitterWnd::OnEraseBkgrnd()
{
return TRUE;
}
|
|
|
|
|
I already did that, but it still flickers the hell out of the screen.
But thanks for the reply.
|
|
|
|
|
How do I pass this structure i.e
struct s_test
{
char Name[15];
}test[10];
to a function??
Thanks,
grahamoj.
|
|
|
|
|
grahamoj, a structure is just a fancy variable, so you can pass it just as you would an int or a float or double. If it's really big, you'll probably want to pass it as a reference:
void foo (struct s_test * t); // the prototype
foo (&test); // the call
If you pass it as a value, you access the structure elements using the . operator; if you pass it as a reference use the -> operator.
Hope this helps!
'til next we type... HAVE FUN!! -- Jesse
|
|
|
|
|
Technicaly that is not a reference, that is a pointer. There is no such thing as passing by reference in C. You could call it a reference if you want to but no one else would know you where actualy talking about a pointer unless you specificaly mention the C language, and then they might figure it out.
// C Memory pointer
void foo(struct s_test* t)
{
int nSize = t->m_Size;
}
// C++ Reference
void foo(s_test& t) // or void foo(struct s_test& t)
{
int nSize = t.GetSize();
}
// C++ Memory pointer
void foo(s_test* t) // or void foo(struct s_test* t)
{
int nSize = t->m_Size;
}
Trust in the code Luke. Yea right!
|
|
|
|
|
Not to pick nits with you, but in the C 'bible' ("The C Programming Language", Kernighan & Ritchie) chapter 1.8 ("Arguments - Call by value") passing arguments by value is differentiated from other methods, which are referred to as "call by reference". Argument passing by value vs. by 'reference' is also mentioned several other places in the book. So, although this technique is implemented by passing pointers, it can be referred to in more than one way.
Still, your 'point' is well taken and your examples illustrate the issue quite nicely, much better than mine did.
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
I see the confusion here...Passing by reference in C means to pass a pointer which means that the called function can modify it. Passing by value means you are passing a copy of the variable.
C++ introduced the concept of the reference type. A reference is like a pointer, but unlike a pointer is must be bound to a specific variable.
K&C have a very good explanation of pass by value/reference and pointers, however that was written before c++ came along. See Stroustrups book on C++ for an explanation of C++ references.
Reference types do not access their members with -> but with .
pass structure by reference in c:
main {
somestruct x;
function(&x)
}
function( somestruct* y) {
y->member = ...
}
same thing in C++
main {
somestruct x;
somrstruct& y = x;
function(y)
}
function(somestruct& ref) {
y.member = ...
}
|
|
|
|
|
Well, I cut my eye teeth on K&R... looks like I should curl up with Stroustrup's book soon.
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
By all means get Stroustrup's book. I just bought the third edition. The 3rd updates it according to the current standard, and adds a description of the standard libraries.
Software Zen: delete this;
|
|
|
|
|
I should have worded my replay earlier differently. I have not needed to read a book on C in years and I have know idea where my copy of "The C Programming Language" is. But here is the way I look at it (and yes I have been influenced by C++).
*pData is a dereferenced pointer (a dereference reference pointer to a memory address) and is therefore a reference to the data its self. In outher words pData could be considered an indirect reference to the data (although it looks like a direct reference to me).
Now then in C++ pData is a pointer to the data and *pData is a reference to the data. I beleive the first C++ compilers converted C++ code to C code and then use the already available C compiler (at least on UNIX).
Wether you agee with the above analiysis is only relevent to the acadimics of the subject though. Do mostly to my influence by C++, I perfer to differentiate between the two, since I do not wish to confuse outhers as to what I am actualy talking about.
Other than my comment, I did make a major mistake in the examples I gave the newbie. I forgot to give examples of how to call the function which sort of defeated the whole purpose.
foo(&myData); // C/C++ pass by address
// C++ pass by value or pass by reference depending
// on wether the function takes a value or refer a
// reference
for(myData);
Trust in the code Luke. Yea right!
|
|
|
|
|
Have you tried using a pointer?
void MyFunction(s_test* pTest)
{
..............
}
|
|
|
|
|
Here's my situation. I know nothing about database programming. I know lots about C++ and MFC and I use Visual C++ 6.0 but also have VS.NET 7.0. Someone has given me a machine with SQL Server and database on it. The database is not very big, maybe 1000 records. I want to get the database off the machine and I want to write an MFC application that will access the data and display it. I want to ship the application and I don't want people to have to have SQL or install anything extra to use the application. I'm sort of hoping that I can convert the database to some sort of file (maybe Access) and query it from MFC. The application would ship with the data and all reading and querying from the file would be local to the machine that the application is installed on.
How would people get started with this and does anyone have any ideas on how to proceed.
Thanks,
Brent
Brent Corkum
|
|
|
|
|
You can use an access database with ADO however this will require your users to have a recent version of MDAC http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid=28001860[^] which is several MB. Also I think the recent versions do not include JET which is the driver that you need. I switched to MSDE a few years ago because of this reason and for the more advanced SQL queries that are available with MSDE and SQL Server.
John
|
|
|
|