|
[quote]
Sorry, for the late reply.
[/quote]
No problem, holidays are holidays
[quote]
Whereas for the X1, Y1 and Z1 is to keep on reading it
[/quote]
Ok, but did you check what I said you about "ADCON0"?? and about the endless loop / initialization of variables?
[quote]
If there is the changes of value >15 or <15
[/quote]
Not sure about what you mean... Changes bigger than 15 units in one or the other direction? or just a value different of 15?
If the first, then you can do (absolute value or module) |lastValue - actualValue| > 15
If the second, then actualValue != 15
Put the conditions in an IF and then call your function.
[quote]
For ADRESH and ADRESL, I did some researched on it. It is used to convert the analog signal to digital. If we used WATCH on the MPLAB, it will able to show the value there. However, I am not sure if I have to include any library (.h) file in my programming.
[/quote]
If you need to use specifical functions to interact with them (and it seems so), I am not sure but I think you will do have to include something, a library, a header, a dll or whatever the components need.
Sorry, but your program is very, very specifical and the extern components make it even harder to follow/understand what happens. I have no experience at all with them. I have given you some feedback about what I saw at the first sight, but I can not help you in a deeper way.
I hope you can solve it.
My last tip is:
Investigate a bit more, and reask in a future. But not just repeating the question: improve, change and make it more specific. Demostrate that you have done research and tried to solve it, but put a link to this thread in your new question, so the people can get the scenario and read all your comments / additional information.
I would make it in parts, first try to do a good structure for a C program. Puting pseudocode and a lot of comments where you need to do the external interactions, but in fact only doing tiny actions just to check if that part of code is executing as you want or not. Once you have your C program, continue with only one external component and get it to work, then the next one. If you try all at once, you will have a lot of potential error-factors and will be very, very difficult to isolate where the problem is.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hello everyone !
How to use SendMessage or PostMessage to send "ALT + A" event ?
SendMessage(hWnd,WM_KEYDOWN,VK_MENU,0);
SendMessage(hWnd,WM_KEYDOWN,'A',0);
SendMessage(hWnd,WM_KEYUP,'A',0);
SendMessage(hWnd,WM_KEYUP,VK_MEUN,0);
why not ?
|
|
|
|
|
wangningyu wrote: How to use SendMessage or PostMessage to send "ALT + A" event ?
SendMessage(hWnd,WM_KEYDOWN,VK_MENU,0);
SendMessage(hWnd,WM_KEYDOWN,'A',0);
SendMessage(hWnd,WM_KEYUP,'A',0);
SendMessage(hWnd,WM_KEYUP,VK_MEUN,0);
I think that when ALT is pressed, windows posts a WM_SYSKEYDOWN and not a WM_KEYDOWN . You should fireup spy++ and try pressing ALT+A on the said application to see what messages are actually posted (and in what sequence). You could try posting the same from your program.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
You can consider using SendInput() or keybd_event() function.
|
|
|
|
|
This function can used if only that the window be the first windows.
I want it behind.
|
|
|
|
|
So, you could use PostMessage as you rightly indicated in your original query. Did you try my suggestion of finding out the messages posted with spy++?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Then I think you can proceed with what Rajesh has suggested. Use Spy++.
|
|
|
|
|
HI,
I have a CString csPoints=_T("122/23/45/90");
how can i split the above string and need to get the numeric values from the above string..
|
|
|
|
|
kumar sanghvi wrote: have a CString csPoints=_T("122/23/45/90");
how can i split the above string and need to get the numeric values from the above string..
You might use AfxExtractSubstring()[^].
CString has three methods - Mid[^], Right[^], and Left[^]. You may use these functions. Sorry, brain fart.
And for converting a string to a number, you could use something like _ttoi[^]
“Follow your bliss.” – Joseph Campbell
modified on Wednesday, December 23, 2009 1:06 AM
|
|
|
|
|
Good finding
Величие не Бога может быть недооценена.
|
|
|
|
|
Well thank you.
But you've selected the "rant" icon (for your message type), which should be used while you're angry about or ranting about something.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
|
Command line error D8016 : '/MTd' and '/clr' command-line options are incompatible
I got this error when i change my Common RUntimesupoort to \clr.
Because i want this option told by some article to use WPF and C#dll in my project.
How can i avoid this error?
I have coonvert vc6.0 to VC++2008.
Anu
|
|
|
|
|
|
I've got a problem trying to define / restrict function accessibility in C++ classes. I'm using the VS2008 compiler, since that does make a difference -- there's a solution using a friend helper class that worked prior to VS2005 but doesn't any more since MS fixed a bunch of conformity error in the later compilers.
I have a base class, an asynchronous callback coming from the OS, and a derived class. The async callback needs to manipulate some of the private variables in the base class. The derived class must NOT be allowed to manipulate those variables and, as such, cannot be allowed to call the function that does so.
My question is how do I modify the following code snippets to do what I want. Don't worry about re-entrancy issues with the callback - that's been removed for the sake of clarity.
baseclass.h
class BaseClass
{
public:
BaseClass ();
void BaseFuncA ();
private:
void CallbackFuncA ();
}; baseclass.cpp
void CALLBACK AsyncCallbackFunc (DWORD dwParam)
{
((BaseClass *) dwParam)->CallbackFuncA ();
}
void BaseClass::BaseClass ()
{
}
void BaseClass::CallbackFuncA ()
{
} derivedclass.h
#include "BaseClass.h"
class DrvClass : public BaseClass
{
public:
DrvClass ();
void DerivedFuncA ();
}; derivedclass.cpp
void DrvClass::DerivedFuncA ()
{
BaseFuncA ();
}
Thanks!!
Judy
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
How about overriding the function in your derived class, and having the override perform something meaningless, while only the base implementation of the function does the variable manipulation?
|
|
|
|
|
It's more a question of preventing the derived classes from calling the function. I'm looking for a compile-time way to enforce my rule rather than depending on the goodness of the derived class'es writer -- me in this case, so this is something of an academic discussion since I am, by definition, most definitely good.
The basic issue is how to make the function private with respect to derived classes yet somehow allow a callback who only has a class pointer to call the function. I can't pass a direct pointer to the function as the parameter to the callback because of the nature of the OS function that sets up the callback. It only takes one parameter but can initiate multiple callbacks. I only showed one in my example code to make life simpler.
Judy
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
I see. I wish I knew a way to do that. Good luck.
|
|
|
|
|
Sounds like the base and derived classes are inverted. The data you want to protect should be in the derived class and not in the base class. Then you could pass in the pointer to an instance of the derived class to the OS function. Depending on your other needs, the base class could implement the do nothing function that accesses the private data it doesn't have. If you need polymorphism, that fuction could be virtual and possibly even abstract.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Tim Craig wrote: Sounds like the base and derived classes are inverted.
The base class contains the basic communications logic for talking to a chunk of hardware, things like Initialize, Uninitialize, the low-level details of sending a series of bytes, and the asynchronous callbacks from the hardware detailing hardware state, along with get-type accessors for the derived classes to test the details maintained by the base class. The derived classes contain things like formatting and validating a particular class of message and then synchronously calling the base class to send that message. The base class needs to hide things like the OS handle to the hardware and the event used to synchronize access with the callbacks. I structured it this way because the same basic hardware can operate in different modes (not controlled by the base class), each of which requires a different messaging format but not a different low-level communication scheme.
Judy
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
Maybe an inheritance hierarchy isn't what you need then. Instead of a "is-a" relationship with your base class, you derived classes should have a different base which has a "has-a" relationship with the current base?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
I'm half asleep, simple-minded, and can't figure out what I'm missing here.
Your program is separate from the OS, but is providing a callback to the OS. I would think that means that you have to be providing the OS with the address of your callback function. It looks like you are putting the callback implementation in the same compilation unit as the class in question. Why doesn't making your callback a private, static member of your class do the job?
|
|
|
|
|
A static member wouldn't have access to the private data of a particular instance of the class.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
The callback gets a parameter which is a pointer to the particular class instance it is to deal with. Is it no longer allowed to use that pointer to access members of that particular instance?
modified on Wednesday, December 23, 2009 1:40 AM
|
|
|
|
|
True enough. But her main problem is that for whatever reason, good or bad, the derived classes shouldn't be able to see the private parts of the base class. Seems like a poor design to me but then it's not really clear why the requirement. Might just be a matter of documenting it so future developers know the runs on how to use the class and why. That stuff most developers never do.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|