|
Ys I can create the DLL but I want to know how we can add the custom class for the Button which is drived from CButton in the DLL, so that I can use that dll in my sdi application to create the button.
Thanks,
|
|
|
|
|
OK, so you can make a DLL.... Check.
And this is in MFC... Check.
So, there's only a few simple things to do:
1/ Make a header somewhere that both the dll code, and the later exe code can read. (I have a workspace include directory, normally).
Near the top, have code like this:
#ifdef IAINDLL
#define IAINEXPORT __declspec(dllexport)
#else
#define IAINEXPORT __declspec(dllimport)
#endif
When you write your CButton inheriting class, start like this:
class IAINEXPORT CIainButton : public CButton
{
};
In your project settings, make sure to add the following symbol to the defines: IAINDLL. That way, when code in the DLL sees the header file, it says "oh, this will be exported!", and when code elsewhere sees the header file, it says "aha, I will link to these class functions".
If you don't know how to write a custom CButton class, then Button Controls[^] is full of examples for you to follow.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
Hi,
I want to write an addin for visual studio, that will display a tooltip showing a certain datamember, when I hover the mouse over a MyClass object f.ex. Is this at all possible? I don't know how to get the information about what the mouse is hovering over. I need some links to reference docs. Thanks!
modified on Tuesday, May 18, 2010 8:32 AM
|
|
|
|
|
_Worksheet objSheet;
Range objRange;
-----------some code here----------------
objRange = objSheet.GetRange(COleVariant(A1),COleVariant(K4));
//at the following line I got the memory leak memory of my programme get increase
ret = objRange.GetValue2();
How to solve that problem
Trioum
|
|
|
|
|
How do you know there is a leak? What are the types of the variables?
Steve
|
|
|
|
|
_Worksheet objSheet;
Range objRange;
-----------some code here----------------
// code to obtained the excel sheet pointer
objRange = objSheet.GetRange(COleVariant(A1),COleVariant(K4));
//at the following line I got the memory leak memory of my programme get increase
ret = objRange.GetValue2();
As I call the ret = objRange.GetValue2(); memory occupied by exe getting increased.
I see in task manager -> process . I have a timer of 1 second which poll data every secong form the excel file . if I do not start timer then there is no memory increase in excel file .
Trioum
|
|
|
|
|
Hello everybody,
I created a service which runs nicely on my local machine.
If I like to test an existence of a file, which is located on a network-folder (net use g: \\...)
then the function _access returns me -1 (not exists).
If I call exactly the same function with the same filename in a standard application (not as a service)
then all works fine.
Is it an access-security problem, or do I use simply the wrong function to test the existence of a file?
(I don't wanted to use a fopen,fclose)
Big thanks for any ideas
|
|
|
|
|
what account is your service running under - default localsystem ?
if so, you'll need to change that so that the account you run under has network access (localsystem by default does not have network access, this includes shares iirc).. create a dedicated account for your service, give it the correct access, its better than localsystem
(if you google around a bit you should find more pointers on the same)
'g'
|
|
|
|
|
If your service runs under the local system/local service account, it has no rights to access network resources.
Try the network service user or create a new user and assign the login to this service.
Greetings
Covean
|
|
|
|
|
Big thanks for your replies.
That seems logic, but it doesn't work ... it's seriously a configuration problem.
I'll make a workaround
Thanks you two
|
|
|
|
|
Try to see what GetLastError returns immediately after the call to __access, it might tell you something. There's a tool in Visual Studio that will give you the error text for each error id.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hello
I want to make a timer in maze.The timer should countdown to reach 0 and if the player doesn't reach to end he/she lose the game.
I want to denote that if player reach to end timer should stopped working.
How can I do it?
Thanks anyone help me.
|
|
|
|
|
I hope that you have the code for your "maze".
What kind of application is it? Assuming your main thread has a message pump, you could run a timer on a separate thread, and have it post a message to the main thread after the time is over. There may be other messages to be processed in the queue, but then again, Windows isn't an RTOS...
Workout progress:
Current arm size: 14.4in
Desired arm size: 18in
Next Target: 15.4in by Dec 2010
Current training method: HIT
|
|
|
|
|
|
Create a secondary thread with a CTimer and a countdown counter; I don't think this is much difficult.
At each "pulse" (either compare delay or Sleep), send a message to the main application thread to display the time left and when the countdown is finished, send a message to the main application to display "You FAIL".
Max.
Watched code never compiles.
|
|
|
|
|
Why bother with a secondary thread if you're going to use window messages to inform the main thread? A vanilla timer set using SetTimer[^] is quite capable of achieving the same result more efficiently.
Steve
|
|
|
|
|
|
Sir, Here is your timer hasani2007. Its in 'dirty c code', clean it up.
set the variable count_down_time_in_secs in seconds for desired count down time.
The Code is self explanatory.
1 minute = 60 secs
5 minutes = 60x5 secs
30 minutes =60x30 secs
1 hour = 60x60 secs
#include <stdio.h>
#include <time.h>
int main ()
{
unsigned int x_hours=0;
unsigned int x_minutes=0;
unsigned int x_seconds=0;
unsigned int x_milliseconds=0;
unsigned int totaltime=0,count_down_time_in_secs=0,time_left=0;
clock_t x_startTime,x_countTime;
count_down_time_in_secs=10;
x_startTime=clock();
time_left=count_down_time_in_secs-x_seconds;
while (time_left>0)
{
x_countTime=clock();
x_milliseconds=x_countTime-x_startTime;
x_seconds=(x_milliseconds/(CLOCKS_PER_SEC))-(x_minutes*60);
x_minutes=(x_milliseconds/(CLOCKS_PER_SEC))/60;
x_hours=x_minutes/60;
time_left=count_down_time_in_secs-x_seconds;
printf( "\nYou have %d seconds left ( %d ) count down timer by TopCoder
",time_left,count_down_time_in_secs);
}
printf( "\n\n\nTime's out\n\n\n");
return 0;
}
.
.
.
TopCoder
|
|
|
|
|
A busy loop is perhaps not the best way to go about things.
Steve
|
|
|
|
|
Hi Folks,
nothing like coming late to the party but as no one has mentioned the way most games are written I thought I'd stick me oar in...
In any game the timing is worked into the main dispatch loop. Every cycle around your dispatch loop you grab input, you update the timer, evolve the rest of the system based on how much time has elapsed and then render the game world according to what's happens. It looks something like this:
unsigned last_time = get_current_time_in_ms();
while( true )
{
update_IO_state();
unsigned time_now = get_current_time_in_ms();
unsigned ms_this_loop = time_now - last_time;
last_time = time_now;
evolve( ms_this_loop );
render();
}
All the functions take some additional parameters depending on how you store your game state.
The key point of this lot is that the game hammers along flat out - the thread this is on will eat a CPU. It churns out frames as often as it can and slows down when there's something system intensive happening. Oh, and if you do your IO on another thread make sure everything is synchronised properly or something weird WILL happen, possibly not on your computer but on your first customer's computer.
Hope that helps,
Cheers,
Ash
|
|
|
|
|
I am dealing with a simple program in c(win32 console).
the program should be able to print first n sentences of y=1-x+x^2/2-x^3/6+...+(-1)^n(x)^n/n!
but I can't do it because I should program with recursive function.
IS THERE A FRIEND HELP ME...
|
|
|
|
|
Try first to code recursively the factorial function (it would be a good starting point) then you if you have problems with it, ask here.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can you code it iteratively?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi all,
I'm doing some simple stuff to get used to MSVS. I've created a simple SDI with MS Access database support that display the keyboard pressed to the dialogue and store the keyboard pressed to the database. However, all i've got is only the beeps when I pressed the keyboard, even if I take the main portion out and just print a test.
Anyone any ideas? Here's the code anyways:
void CTest9View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
m_stest = char(nChar);
CRecordView::OnKeyDown(nChar, nRepCnt, nFlags);
}
Thanks for any help in advance
dnqhung
|
|
|
|
|
Hi,
Somewhere in your implementation file for your view class you should see a horrific looking block of macros. It'll look something like:
BEGIN_MESSAGE_MAP(CMFC_testView, CView)
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
ON_WM_KEYDOWN()
END_MESSAGE_MAP()
Has your block of macros got the line ON_WM_KEYDOWN() in it? If it hasn't then try sticking it in and seeing if the code starts magically working.
If it doesn't work then perhaps a session of delving into how MFC routes messages might be in order. Paul DiLascia wrote a decent article on it years ago for MSJ ("Meandering Through the Maze of MFC Message and Command Routing" http://www.microsoft.com/msj/0795/dilascia/dilascia.aspx[^]) about it and tells you why you need all those funky macros and why message handlers aren't virtual.
Hope that helps,
Cheers,
Ash
|
|
|
|