|
I would just send all the windows a user defined message #define WM_MY_MSG (WM_USER + 1). Using the ON_MESSAGE macro to handle the mesage in the view. You can make this message handler do what every update is doing..
void CMyApp::SendMessageToEverybody(UINT nMsg, WPARM wParam, LPARM lParam)
{
} Hack on...
Jonathan Craig
www.mcw-tech.com
|
|
|
|
|
I have a Windows explorer type program, that talks to a printer via a serial link. The printer stores many files internally. When I drag a file across from the printer to Windows explorer, I need to somehow get Windows explorer to download this file.
Or I need to get information about where the files were dropped in explorer, so my app can start the download. ActiveSync does such a thing, so it must be possible!
I can handle it when explorer drops files on my app, but not vice versa.
Any help or advice is very welcome!
Thanks in advance,
Alan Dugdall
|
|
|
|
|
Hi All
Has anybody here communicated via VC++ to a chain of hardware devices via the RS232-485 converter?
If so any documentation regarding the comm. to the converter or any weblinks to the resources is greatly appreciated
Thanx in advance
Agnihothra
|
|
|
|
|
Yes and they work just fine. No real documentation required because they are pratically idiot proof. If I remember my specs right, all you usually need to do is support hardware flow control and then the 485 convert does the rest.
That is if I remember my 485 right. I never can remember which one of 485 and 422 is just a simple RX/TX and which has the extra control lines for who wishes to access the wire.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I am new at VC++ but i didnt understand the pointer thing.
Why we use them? Where we need them? Please,someone help me!I want to know ALL REASONS why we use them.Thanks to everyone.
|
|
|
|
|
I think different: why is not everything a pointer?
Pointers give more flexibility & efficiency. In some cases you want the value not the reference, there you (maybe) don't need pointers. But with at least bigger data stuctures you want back your pointers, e.g. copying data from/to stack is not optimal.
|
|
|
|
|
cause data has to be stored somewhere, the pointer has to point somewhere...
|
|
|
|
|
agreed
|
|
|
|
|
Hmm, well, it has many advantages. Of course I can't remember all of them. But here are some.
1. Stack of the program is limited, and it is used for regular variables. Ponters are limited only by amount of memory in the computer, not on the stack.
2. When you have a class for example, which uses for example 100Mb of the memory. Now passing the variable to another function will make a copy of the class and you will have 200Mb of memory usage. Instead of this you can pass a pointer, which holds only 4 bytes. Actually this one is same as ByRef in VB - reference (you have references in C++ too).
Well, can't remember more right now, but sure others will find you enough
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Try reading my article on pointers for an introduction to the subject, and feel free to make comments in the discussion area of the article.
--
Andrew.
|
|
|
|
|
I'm no expert but here's 4 reasons for using pointers
1. They allow functions to modify their calling arguments.
2. Data is more easily passed around ie passing 1 pointer is easier than passing a whole object.
3. Data may be more easily accessed, for instance when data is stored in an array a pointer allows you to move through the array in a loop to access each item.
4. They allow you to dynamically allocate memory, this is good because it is more flexible than fixing memory allocation when programming.
Hope that helps
ali p
|
|
|
|
|
Since you say you're new at VC++, what follows may make little sense to you, but hopefully you'll grasp the idea soon.
If you're into OOP, many objects will be derived from a common base. Usually, a piece of code uses such object without really knowing the particular class they belong to (only that they're derived from the base). In this situation, passing by value (without pointers) is impossible, since the code won't know in advance how much space will take the object (different derivations can have more or less members not belonging to the base), so no copying around can be performed. I this case, the only solution is to pass to the unknowing code a pointer to the actual location of the object, so preventing copying.
In Java and C# the situation is the same, but the language hides this to you by making implicitly every object variable a pointer to an object --so these languages have pointers but you can't see them.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I've just read in a web site that using pointers have 3 main reasons:
Array Operations,Dynamic Memory(variable sized arrays and structs like linked lists) and Parameter Passing.I've read something about this polimorphism thing,too but i didn't understand any word
Now,are these 3 reasons enough,or is there something more?
|
|
|
|
|
It is a most bizarrely mocking fact that a lot of C++ programmers realize the worth and splendor of pointers only when they start using a language which does not support them directly.
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Some people call C++ the mid-level language. What does "mid-level" mean? Not as high level as Java or VB is (everything you need is just out there: Java has Virtual Machine, and the VB development tool does a lot of things for programmers. ); and not as low level as assembly language is (push, mov, eax, ..... ).
As sort of mid-level language, C++ covers both features of high and low ones. C++ is a structured language and uses 47 ( +1 : 'typename' ) English keywords, and the syntax is close to a certain human speach (if... else. do... while. try...throw... catch... ).
Then, what feature C++ covers as low-level one? Direct access to memory! How? With the feature of pointers, we can.
For example, if you want to set some desired value to somewhere in the memory, we may use:
int* p = (int*)0x0FCC00;
*p = 123456;
Or you can view where the variable is, you can code such:
double dMyMagicNum = 3.1415926535897932384626433832795;
printf("dMyMagicNum is at 0x%p \n", &dMyMagicNum);
There is also a trick called "Placement memory allocation".
If you had allocated some memory in the free store:
char* buf = new char[sizeof(int) * 300];
int* p = new(buf + 6) int;
printf("Buf: 0x%p, p: 0x%p\n", buf, p);
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
I'm working with a text box (CEdit), but unfortunatly, there aren't any functions to change the text color.
I would like to know what is the easiest way to make a text box with different lines of text in different colors. There are quite some syntax coloring edit boxes out there, but they have way too many features.
Even a rich edit control (Working in a dialog) doesn't seem to support this easily. (you have to select parts of the text or something, then you can change a mask...)
Maybe it can be done with OnCtlColor, but then I can only change the text color of the entire Dialog...
Got any ideas?
|
|
|
|
|
Griffith Sutherns wrote:
Maybe it can be done with OnCtlColor, but then I can only change the text color of the entire Dialog...
Nooo!
You can check and see if nCtlColor is CTLCOLOR_EDIT if you want to change the color for every edit control or you can call GetDlgCtrlID on the pWnd which is a CWnd*, and chk if it's the specific edit control
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
unfortunately, you'll need to use one of those syntax coloring edits, if you want to have multiple text colors in a single control. the basic CEdit only allows one color for text. it's hard to believe i know (my own syntax coloring editor implements the whole edit control thing from scratch - just to be able to color text)
there are some classes that make rich edit use easier, especially if the text is read-only. and, even better, you could use an embedded instance of an HTML browser if your text is read-only (it's really quite simple).
-c
There ain't no second chance
Against the thing with the forty eyes, girl
|
|
|
|
|
I'd solve this by using a ritchedit control, but instead of modifying the content, I'd generate some RTF (on the fly if necessary) with color codes in it and do a StreamIn.. it might sound complicated but it only takes a few lines of code and a simple callback function.
Cheers!
Marc.
|
|
|
|
|
Good idea. I'll try that
Thanks for the feedback!
|
|
|
|
|
Hi,
I need to create a program that could have the possibility of kill some exe's running ( I would send a notification to that exe's and if they don´t answer they are hanged.. so kill'em and restart them...).
The problem that I found is that I can only kill an exe if the process that wants to kill it, it´s the same the created it, ... is there another way to do that, or that is reserved to the Task Manager ?
Thanks in advance, greetings
Braulio
|
|
|
|
|
you need to have SE_DEBUG_NAME privilege, then get a Handle to the process with OpenProcess() then call TerminateProcess() to kill the process
HANDLE OpenProcess(
DWORD dwDesiredAccess, // access flag
BOOL bInheritHandle, // handle inheritance option
DWORD dwProcessId // process identifier
);
BOOL TerminateProcess(
HANDLE hProcess, // handle to the process
UINT uExitCode // exit code for the process
);
|
|
|
|
|
Thanks !
One question more, could you tell me a little bit more about the SE_DEBUG_NAME privilege ?, is a privilige that I set to my process or to other processes or... ?
Thanks a lot, greetings
Braulio
|
|
|
|
|
HANDLE hToken;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
{
if (EnablePrivilege(hToken, SE_DEBUG_NAME, TRUE))
{
.....
}
BOOL EnablePrivilege(HANDLE hToken, LPCTSTR szPrivName, BOOL fEnable)
{
TOKEN_PRIVILEGES tp;
tp.PrivilegeCount = 1;
LookupPrivilegeValue(NULL, szPrivName, &tp.Privileges[0].Luid);
tp.Privileges[0].Attributes = fEnable ? SE_PRIVILEGE_ENABLED : 0;
AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL);
return((GetLastError() == ERROR_SUCCESS));
}
|
|
|
|
|
Usually killing apps is done by posting a WM_CLOSE to their main window. But I guess you want to kill non-responding apps as well.
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|