|
Thanks,
But it cann't help me because i want my controls inside a dockable dialog to
be resizable like in CResizableLib of Paolo Messina.
|
|
|
|
|
But you can derive Cristi's CSizingControlBar and put anything you want inside. I made it several months ago with a resizable child dialog containing listview, static and button controls. You only need to reposition the child dialog when the control bar is resized, then to override the OnSize handler in the child dialog to reposition correctly its controls.
|
|
|
|
|
I'm trying to detect when the user presses Ctrl/End. My PreTranslateMsg() override always computes the Ctrl key as not being pressed. Obviously, I'm doing something wrong. A gentle nudge in the right direction would be appreciated.
BOOL CMyCtrl::PreTranslateMessage (MSG* pMsg)
{
BYTE pressedKeys [256];
ZeroMemory (pressedKeys, sizeof (pressedKeys));
VERIFY (::GetKeyboardState (pressedKeys));
bool bCtrl = (pressedKeys [VK_CONTROL] & 255) == 255;
if (pMsg->message == WM_KEYDOWN) {
switch (pMsg->wParam) {
case VK_DELETE:
m_pModel->notifyDeleteKey();
break;
case VK_RETURN:
m_pModel->notifyEnterKey();
break;
case VK_HOME:
case VK_END:
case VK_LEFT:
case VK_RIGHT:
case VK_UP:
case VK_DOWN:
m_pModel->notifyNavKey (pMsg->wParam, bCtrl);
break;
}
}
return CWnd::PreTranslateMessage(pMsg);
} My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib@ravib.com
|
|
|
|
|
Does End send WM_KEYDOWN or WM_CHAR ? If so, I'd use GetAsycKeyState to check if Control was down at the same time.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am with Christian on this one. When I track regular virtual key presses, I always use GetAsycKeyState to test for the CTRL, SHIFT, etc. I have always experienced seriously mixed results with the GetKeyState function, so I don't use GetKeyState anymore.
This note in MSDN for GetKeyState about sums it up for me:
The key status returned from this function changes as a thread reads key messages from its message queue. The status does not reflect the interrupt-level state associated with the hardware. Use the GetAsyncKeyState function to retrieve that information.
|
|
|
|
|
This is what I use...
<br />
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_END)<br />
{<br />
BOOL bCtrlKeyDown = ((GetKeyState(VK_CONTROL) & ~1) != 0);<br />
<br />
if (bCtrlKeyDown)<br />
AfxMessageBox(_T("woof, woof"));<br />
}<br />
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
Painted on the side of a dog trainer's van: SIT HAPPENS
|
|
|
|
|
if ((GetKeyState(VK_CONTROL) & 0x8000) )
This works for me nicely.
Einstein: "Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
My Articles
|
|
|
|
|
Gak! I was & ing with 255 instead of 0x8000 ! Thanks, guys!
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib@ravib.com
|
|
|
|
|
When I create my worker thread and pass a char array, will my data be lost if in my main app I wrote over my char array with new data? Here is my thread creation code:
<br />
CWinThread* thread = AfxBeginThread(MyIOThread, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);<br />
thread->m_bAutoDelete = TRUE;<br />
thread->ResumeThread();<br />
<br />
Here is my worker code:
<br />
UINT CLAQTermDlg::MyIOThread(LPVOID pParam )<br />
{<br />
CLAQTermDlg * myDlg = (CLAQTermDlg *)pParam;<br />
<br />
::MessageBox(NULL, myDlg->sText, "In my Thread", MB_OK );<br />
return 0;
}<br />
Will the myDlg->sText be over written if in my main app I write over it with something else?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Yes. Threads share the same memory space as the other threads within the program.
Worse, if you modify that same string from your main thread and worker thread at the same time, you might get some unprdictable and undesireable results.
Data access like that should be protected with a CriticalSection.
|
|
|
|
|
Blake two quick questions
1. Would I put my critical section around my char array before I make my call to AfxBeginThread, or do it in my thread around the myDlg->sText char array.
2. Would it be wise to have another char array in my thread that I move this data off to and release my critical section?
Sorry I forgot a question.....If I create a char array in my thread does it have it own unique memory space each time a thread is created?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
1. You need to protect a string at the time the string is accessed.
If you really want to display the messagebox, I would make a local copy, but protect the copy process with the critical section.
UINT CLAQTermDlg::MyIOThread(LPVOID pParam )
{
CLAQTermDlg * myDlg = (CLAQTermDlg *)pParam;
CString csMessage;
EnterCriticalSection(...);
csMessage = myDlg->sText;
LeaveCriticalSection(...);
::MessageBox(NULL, csMessage, "In my Thread", MB_OK );
return 0; //Thread completed successfully
}
2. If you need the data longer, then make a variable as part of your thread class or a local variable in the thread function, and perform a protected copy, similar to above example. You also need to use same critical section in other parts of your code wherever the myDlg->sText is modified or accessed.
3. The array would be unique if it is local to the thread function or else if it is a member variable of a derived thread class, since you would be creating an instance of the thread class for each thread which is run. Just don't declare the member variable as static or it is shared among all instances of a class.
|
|
|
|
|
I'm trying to write a program that is based off of data from a database program. The only problem is, I want data from the database program that is only available if I print it to the printer. However, I can choose the 'print to file' option and the information is put in a .prn file. My question, then, is does anybody know how to read from a .prn file in C++? Some characters may be readable, but others are junk.
Danny
|
|
|
|
|
I did something 10 or 15 years ago, using Borland Turbo C++3, to clean up an OS-2 print file, so I could use it in DOS / Windows 3.1. The problem was that my OS-2 print-to-file contained tables, etc, which did not translate well to the Windows default character set.
As far as I remember, my approach was brute force, and it worked quite nicely! Basically, the flow was something like:
do while not EOF()<br />
read character from file as a byte value<br />
if character is a special character<br />
replace special character with standard character<br />
do something with character<br />
Some points worth noting:
1. This is a lot easier (fewer strange characters) if you choose a really simple printer - install a Generic / Text only printer in Windows.
2. I decided how to deal with special characters by doing a simple print to a printer and the same print to a file, and comparing the print file with the paper copy. This was in DOS days, so I also had to take care of converting the PC line-drawing characters to "|", "-", "+", etc.
3. According to my flow above, it may be easiest (least change to your existing program) to create a temporary "cleaned" text file from the print file, then use the cleaned file as input to your file-to-database program.
|
|
|
|
|
Thanx, I'll see what I can do with this. Right now, in the file, I see a bunch of those funny boxes, but maybe my program will be able to read something from them.
Yesterday is history
Tomorrow's a mystery
Today is a gift
That's why they call it the present.
Danny
|
|
|
|
|
Good luck.
As I indicated, a key part of what I did was to read the print file byte by byte as unsigned char, identify "bad" values, and replace "bad" values with "good" values using a Switch statement.
|
|
|
|
|
i want during writing code on the vc6 editor to press a short cut and get a color picker panel and
choose one of those color so its hexadecemal code is written in the editor how can i do this
how do i add this capability to vc6 editor if it is not found ?
MSaty Bottom Up Gamer
|
|
|
|
|
There is a common dialog class for the color picker that you're used to seeing. It's also possible to write your own, there are at least a couple that do HLS here on code project.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
and how can i make this dialog class run in the editor of the visual studio 6 environment, i mean
while i am writing code to any program i want the dialog class to be a feature in the visual studio
environment, righ click and one of those pop up options is _ color picker _ i hope my question is
clear...;)
MSaty Bottom Up Gamer
|
|
|
|
|
Well, then you'd have to write a visual studio add in. The question would be - why ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi im trying me on Debugger
I´ve injected a dll into a Application. I can see the assambler code ( using engine to convert from binary code ) and I can list all dlls that this app uses.
My next step is to getting all thread of an application. I searched here and looked on MSDN but i cant get the information i searched.
How to get the ThreadID, ThreadEntry and Data Block of all thread in a process ?
|
|
|
|
|
How about the Thread32First() /Thread32Next() pair?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
What are you doing with a DLL injected into the process?
1. Why don't you use the supplied OS APIs that enable you to debug?
Debugging API[^]
These APIs enable you to write a debugger, they don't write it for you. So it's no easier using them than it is doing what you are currently doing. The only thread you would ever need to create in the process would be "debugbreakpoint" to break into the application and debug it. Sure you could manually attempt to freeze all threads and things without the debug API, however those are trivial tasks that are already implemented. Why not spend your time enabling features than implementing the most basic of functionalities.
2. You shouldn't be calling any "debugging" functions from inside the process.
Why? Because this application is being debugged. You don't know the state of the process and you are affecting it by being in the same memory space. If you freeze all the threads as well (Which is what generally occurs with debugging) you then have the problem that if one thread is say holding a heap lock in the middle of an allocation, you could deadlock your debugging thread. The debugger should be seperate from the application.
Creating a basic debugger[^]
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
If you already are using the debug API, then like I said everything you are doing can be accomplished from a seperate process no need for DLL Injection.
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
Well I never informed me about the debug api. In my oppinion it was the easiest way. With my Method theres no need to reset the debugging flag ( There are many Apps that detect if a debugger is active ). But after reading the Article you´ve post i must think about my concept. Thx for help.
|
|
|
|