|
Have you got some links to this articles?
I have such found articles about C#, but I search a solution for C++.
thanks
blue-marie
|
|
|
|
|
|
I do not have a solution, but I do have a suggestion. If you can not find an example of drawing custom menus in MSDN, a book or on the www, then you could look at one of the projects at CP or elsewhere that use MFC and work you way backwords. That is examine what messages (see "Menu Messages" in MSDN) you need to handle and how they are being handled.
Good Luck!
INTP
|
|
|
|
|
I am trying to access the msaccess file throught odbc dsn
seemslike the password and user name set in dsn option is not
working is there something i have to do inorder to enable this
security?
Shinya
|
|
|
|
|
Maybe yout DSN connection is not properly configured. Try this. If it does not work, send me the full specs of you database (name,location,username and password)and i will build a small application to sort this out for you.
Cheers
Krugger
Plan tomorrow todays cos' tomorrow will be too late...
|
|
|
|
|
Hi,
Until today I used timers on dialog based applications and the app wizard did all the work of setting up the message map etc.
If I have a regular c++ class, how do I use timers on it ?
Any short example will be helpful.
Thanks,
Shay
|
|
|
|
|
on MFC, you can use CWnd::SetTimer() if your delays aren't bigger than 55ms
TOXCCT >>> GEII power
|
|
|
|
|
SetTimer() is used, with or without MFC.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
If your 'regular C++ class' represents a Window then you can use ::SetTimer and handle the message. If it doesn't then you could look at ::CreateTimerQueueTimer , which requires W2000 or later but which will regularly call a function for you.
class HasATimerCallback
{
private :
HANDLE hTimer_ ;
static void CALLBACK TimerFunc ( void * param, BOOLEAN bTimer )
{
if ( param )
{
reinterpret_cast < HasATimerCallback*>( param )->DoTimerFunc () ;
}
}
void DoTimerFunc ()
{
}
public :
HasATimerCallback ()
{
::CreateTimerQueueTimer ( &hTimer_,
0,
TimerFunc,
this,
60000,
60000,
WT_EXECUTEINTIMERTHREAD
} ;
}
~HasATimerCallback ()
{
::DeleteTimerQueueTimer ( 0, hTimer_, INVALID_HANDLE_VALUE ) ;
}
} ;
I haven't compiled this, just cut'n'paste from some code I had lying around.
Paul
|
|
|
|
|
Got the idea, but....
When I try to copile it I get:
error C2039: 'CreateTimerQueueTimer' : is not a member of '`global namespace''
Any idea why ?
shay
|
|
|
|
|
The documentation for CreateTimerQueueTimer here[^] suggests that you have to define _WIN32_WINNT=0x0500 or greater. I usually do this in the project settings, where it may already be set to a lower level. The thread pool functions are only available on W2000 and later, which is slightly constraining but makes for a very quick example.
The documentation also says that the function will be called every 'interval' whether or not the previous call has returned. IOW your timer call back must be 're-entrant'. The Thread Pool functions make life easier but they don't save you from synchronisation issues.
Paul
|
|
|
|
|
I have a problem concerning the preprocessor.
How is it possible to use a #if within a macro?
I give u an example:
#define MACRO( x, y ) \
x *= y; \
#if y == 3 \
x /= 2; \
#endif
void main()
{
int iTemp = 10;
MACRO( iTemp , 1 );
MACRO( iTemp , 2 );
MACRO( iTemp , 3 );
MACRO( iTemp , 4 );
}
Is there a way to do that?
Thx
Don't try it, just do it!
|
|
|
|
|
well, is there a problem with that code ?
it seems to be right, even if i really dislike that way of coding (i prefer inline functions to macros...)
TOXCCT >>> GEII power
|
|
|
|
|
i can't use inline functions here because the code in the macro is not c code... it is SSE assembler code
Don't try it, just do it!
|
|
|
|
|
Why not use this instead?
#define MACRO(x,y) { x *= y; if (y == 3) x /= 2; }
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
here, the "if" test will be performed every time the macro is called, where in the other case, it will be defined only if the y is set to 3.
(you're probably right, in your code, david, but i continue thinking that i prefer inline functions than macros).
TOXCCT >>> GEII power
|
|
|
|
|
The compiler will see if ( 3 == 3 ) or if ( 2 == 3 ) etc and shouldn't actually generate any code for the 'if' statement. Possibly worth trying and checking the generated code to see.
Paul
|
|
|
|
|
thx guys, i will check this.
Don't try it, just do it!
|
|
|
|
|
Paul Ranson wrote:
and shouldn't actually generate any code for the 'if' statement
There is generated code. It looks like:
int iTemp = 10;
{ iTemp *= 1; if (1 == 3) iTemp /= 2; };
{ iTemp *= 2; if (2 == 3) iTemp /= 2; };
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I meant that the compiler wouldn't generate any code for tests that only have one outcome.
This code,
#define MACRO(x,y) { x *= y; if (y == 3) x /= 2; }
int main()
{
int iTemp = 10;
MACRO( iTemp , 1 );
MACRO( iTemp , 2 );
MACRO( iTemp , 3 );
MACRO( iTemp , 4 );
std::cout << "Ends up with " << iTemp << std::endl ;
return 0;
}
in an optimised build turns into
push 120
call ostream etc
IOW the compiler has taken all the fun out of it.
This function
int UseMacro ( int i )
{
MACRO( i , 1 );
MACRO( i , 2 );
MACRO( i , 3 );
MACRO( i , 4 );
return i ;
}
compiles to
?UseMacro@@YAHH@Z PROC NEAR ; UseMacro, COMDAT
; 10 : MACRO( i , 1 );
; 11 : MACRO( i , 2 );
; 12 : MACRO( i , 3 );
mov eax, DWORD PTR _i$[esp-4]
lea eax, DWORD PTR [eax+eax*2]
shl eax, 1
cdq
sub eax, edx
sar eax, 1
; 13 : MACRO( i , 4 );
shl eax, 2
; 14 :
; 15 : return i ;
; 16 : }
ret 0
?UseMacro@@YAHH@Z ENDP ; UseMacro
So I don't think we have to worry about optimising the Macro.
Interesting stuff to look at though, this is VC++ 7.1 and it seems pretty clever to me.
Paul
|
|
|
|
|
toxcct wrote:
where in the other case...
Which is the case that does not work.
toxcct wrote:
(you're probably right, in your code, david, but i continue thinking that i prefer inline functions than macros).
I was not comparing one against the other in terms of speed, efficiency, maintenance, etc. I was just correcting what he was attempting.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi all,
I hope that somebody can help me. I have written a program which slices a 3D part into a set of 2D slices. The amount of data generated by that function can be very large (i.e. greater that 300 MB).
To save main memory I want to save these data into a file. I want to do that in a way to have a fast access to single layers. My current implementation is working like follows:
I have a list of 'int' values for every layer:
n,i1,i2,...,in
'n' is equal to the number of vertices for every layer
i1,...,in are indeces refering to co-ordinates of a corresponding points et.
By attaching all lists together I get a 'int' based representation of the layered representation of the 3D part:
n,i11,...,i1n,m,i21,...,i2m,o,i31,...,i3o,...
I save these data into a file.
To get the data for a single layer I can use the 'n','m' as offset to set the file handle to the right position. That means if I want the data of the third layer I start from the beginning and add the offset 'n'+'m'+2. The file handle is now positioned at 'o'. I use 'o' to read all data of the third layer.
This is working very well and is quite fast. But unforetunatly sometimes the software crashes. It seems that for some reasons wrong data are saved. The offsets 'n','m',... are not corresponding to the file size/lenght of 'int' list.
I have tried out to find the reason for that. This will only happen, if I save the 'int'list to a file. If I hold all data in the main memory there is no problem.
Has somebody an idea, why this is happen? Or a better idea to save main memory with a fast access to the layer data?
Ciao,
f.o.b
|
|
|
|
|
Hi,
Sorry, I don't know what can be the problem, but I have a suggestion to a different approach to your problem. You could use a compound file storage, this is the same as Word, Excel and many other do.
The idea behind structured storage (check MSDN) is to replicate the structure of a file system, folders and files, inside of a file, folder are call storages and files streams. So you create a tree structure of storages and save your data on a stream on the appropriated storage.
Getting the data back is fairly easy, find the storage you are looking for, open it, open the stream, get the data.
The nice thing about this, is you can have meaningful names for your data and the path where is located.
To see what I'm talking about, look for the "DocFile Viewer" application on the "Microsoft Visual Studio 6.0 Tools" and open a Word or Excel file.
If after reading a little you still need more help, let me know and I can give you another push.
Fabian
|
|
|
|
|
I need to charge an image from a PATH...Anybody can help me?
|
|
|
|
|
Hugo Bertorello wrote:
...charge an image from a PATH
What exactly does this mean?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|