|
First:
if (!memcpy((LPSTR)hDIB, vBits, nPackedDIBLen))
well normaly I would have called GlobalLock() to get the pointer, but hDIB is realy a pointer so this should work ( LPSTR should be LPVOID ).
The problem with the line is that vBits points to the start of the buffer, where the BITMAPFILEHEADER is stored and you are trying to copy the information following it:
if (!memcpy((LPSTR)hDIB, (LPBYTE)vBits + sizeof(BITMAPFILEHEADER), nPackedDIBLen))
That should fix the following:
BITMAPINFOHEADER &bmiHeader = *(LPBITMAPINFOHEADER)hDIB ; // Gets wrong data
BITMAPINFO &bmInfo = *(LPBITMAPINFO)hDIB ;
(interesting use of references!)
Try takeing a look at the CDibData article; I wrote the class so that it could take a handle to a DIB (see CDibData::Attach()) just like the clipboard.
INTP
|
|
|
|
|
Hi!
I keep getting a "User Breakpoint called from code at 0x......." I do not have any breakpoints set, but my execution seems to keep halting.
I notice if i comment out a few function function calls, my program works ok. So it seems like this error occurs when my DLL becomes a certain size.
I've never seen this before and dont know where to start trying to figure out where/how to debug it. I'm not doing anything fancy: My project is a multithreaded dll, using MFC as a shared dll. I have classes defined w/ normal inheritance and I'm including version.lib and ws2_32.lib for libraries.
I've never seen my execution simply halt. Any help would be GREATLY appreciated!! TIA.
-C
|
|
|
|
|
what about using a debugger to trace the breakpoint? it is prolly a simple assert statement.
Don't try it, just do it!
|
|
|
|
|
Apparently CFormView doesn't handle Keyboard Accelerators. that is until you have selected a form element like a textbox or list. But since I would rather have the formview recognize an accelerator without having to go in this direction is there a way I can work around this.
I have this solution, but I don't think it is working the way it should or perhaps is the wrong solution. In a nutshell I have the following code which when a document in opened and the form appears, OnInitialUpdate() is called and I call LoadAccelerators and load the handle into a variable. Later I override PreTranslateMessage() and check for this handle then call ::TranslateAccelerator() which I'm thinking takes in a window handle, thus I used my main window handle where at the accelerator keys work, the accelerator handle then the message. Here is the code.
void CFormGameOnView::OnInitialUpdate()
{
m_haccel=LoadAccelerators(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDR_FORMGAMEONVIEW_TMPL));
...
}
BOOL CFormGameOnView::PreTranslateMessage(MSG* pMsg)
{
CMainFrame *pMain = (CMainFrame*)AfxGetMainWnd();
if(m_haccel)
{
if(::TranslateAccelerator(pMain->m_hWnd, m_haccel, pMsg))
return TRUE;
}
return CFormView::PreTranslateMessage(pMsg);
}
Is this the right approach or is there a better approach?
Thanks!
|
|
|
|
|
I've never posted in this board before. This is actullay the first time i've clicked on it.
Anyways, I was reading that in C# the only way to get parallel port access in Windows XP is via a kernal mode driver. Now, I did this and it worked fine.
But, i'm messing around with C, right now and I was using the _inp and _outp functions in conio.h
So, here's my question: Can I get hardware access directly with C in windows XP? Like on 95 and 98 where I can just to _outp and it goes to whatever port I say.
/\ |_ E X E GG
|
|
|
|
|
In case of C too you need a kernel mode driver in win2k and xp
|
|
|
|
|
that's not cool. thanks for your answer.
/\ |_ E X E GG
|
|
|
|
|
|
eggie5 wrote:
Can I get hardware access directly with C in windows XP? Like on 95 and 98 where I can just to _outp and it goes to whatever port I say.
No.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
thanks for your answer.
/\ |_ E X E GG
|
|
|
|
|
This function works great when I compile a project
using Unicode Debug. Is there any similiar function
if I just use Debug mode?
|
|
|
|
|
|
I get
BindStatusCallback.obj : error LNK2001: unresolved external symbol __imp__StrFormatByteSizeA@12
Debug/Setup.exe : fatal error LNK1120: 1 unresolved externals
Its the BindStatusCallback.cpp code that you posted on
December 24, 1999: Version 1.0. Any chance you updated it since 1999?
Please let me know. My email address is brinasas@yahoo.com
The code works fine for Unicode, but in Ansi, I keep getting that
error. Drives me nuts.
I love "...give me credit where it's due. I'll know if you
don't. bwa ha ha ha ha!"
Sincerely
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Hello...
I'm currently writing a program that has to read in data from the serial port and then process it. But I thought before I tackle that part, I should write a small sample one to test to see that I can actually receive data.
I got this sample program off the MSDN website and made a couple of minor changes (original can be found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/monitoring_communications_events.asp ) to reflect the fact that it's supposed to look for any characters received.
#include [windows.h]
#include [assert.h]
#include [conio.h]
#include [iostream]
void main()
{
HANDLE hCom;
OVERLAPPED o;
BOOL fSuccess;
DWORD dwEvtMask;
hCom = CreateFile( "COM1",
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL
);
if (hCom == INVALID_HANDLE_VALUE)
{
return;
}
fSuccess = SetCommMask(hCom, EV_CTS | EV_DSR);
if (!fSuccess)
{
return;
}
o.hEvent = CreateEvent(
NULL,
FALSE,
FALSE,
NULL
);
o.Internal = 0;
o.InternalHigh = 0;
o.Offset = 0;
o.OffsetHigh = 0;
assert(o.hEvent);
if (WaitCommEvent(hCom, &dwEvtMask, &o))
{
if (dwEvtMask & EV_RXCHAR)
{
cout << "received!";
}
if (dwEvtMask & EV_CTS)
{
}
}
getch();
}
This program, when compiled, does not output "received!", even though I know there is data being sent to the serial port (COM1). Any suggestions as to why? Is there a better way to monitor for the reception of characters through the serial port? Any help is appreciated.
Thanks in advance.
|
|
|
|
|
The ReadFile function also has me a bit concerned.
Assuming WaitCommEvent works, and the "event" is that a character has been received (EV_RXCHAR), would this piece of code output the character that was received (data)?
OVERLAPPED obj;
BOOL fsuccess;
HANDLE hCom;
BYTE data;
DWORD event = EV_RXCHAR;
DWORD transferred;
if (WaitCommEvent(hCom, &event, &obj))
{
cout << "IT DETECTED SOMETHING! ";
fsuccess = ReadFile (hCom, &data, 1, &transferred, &obj);
if (fsuccess)
{
cout << "IT READ A CHARACTER: " << data;
}
getch();
}</code>
Oh, in both of the above programs, the serial port is constantly being fed data continuously. Thanks for any help.
|
|
|
|
|
You (or the MSDN example) does not configure the timeout values for the communications port. These timeouts MUST be specified, otherwise the last settings which were effect on the port (by another application or by system defaults) are applied, and may cause serious misbehaviour.
For information how to configure the timeouts and what timeouts are needed, see MSDN with the keyword 'SetCommTimeouts'. Also, if you need a non-overlapped I/O sample, see this CodeProject article and browse through it's source code.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I'd like to make an ActiveX control, but deriving it from MFC's CListCtrl class. Is this possible? I try the regular MFC ActiveX control wizard and choose 'none' for which class to subclass, but when I try to replace all instances of the COleControl, I get a bunch of errors. Can anyone help? I want to do a little extending to the MFC control and allow VB users to use it. Thanks in advance!!!;);)
If it's broken, I probably did it
bdiamond
|
|
|
|
|
It might be that your terminology is a bit wrong, but let's see now...
An ActiveX control is a control of it's very own type. Just like a CListCtrl represents a list control, an ActiveX control represents an ActiveX control
Normally, the ActiveX control contains a normal window. This window can then contain other controls, like the list control you specified.
The most effective way here would be to use the wizards to create a standard, windowed ActiveX control. Then, in the construction routine of the window, initialize a member variable of type CListCtrl. On the creation routine (of the window), create a standard Windows child list control, for which the ActiveX control's window works as a parent.
This way, the actual control class will expose the interfaces that are required to make it an ActiveX control. The window and the child list control can be used just like a normal CWnd-class window that has a list control.
Just remember to add properties and necessary methods to the ActiveX controls for VB users to control all the necessary features of the control. And of course remember to implement all these properties so that they'll also do something
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
thank you!!! that was just what I needed;P;P
If it's broken, I probably did it
bdiamond
|
|
|
|
|
|
excerpted from MSN" The user scrolls the content of a window by clicking one of the arrow buttons, by clicking the area in the shaded shaft, or by dragging the scroll box. When the user clicks an arrow button, the application scrolls the content by one unit (typically a single line or column). "
Question: how to retrieve the size (by pixel) of a unit?
|
|
|
|
|
Do GetScrollRange() , GetScrollPos() , or GetScrollInfo() help?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Is that your Scroll Bar? How did you set its sizes?
Get trial copy of comment generating tool CommentMakerPro, std::string and std::string containers viewer FeinEvaluatorPro and windows manager for Microsoft Visual Studio .NET FeinWindows at www.FeinSoftware.com
|
|
|
|
|
Hi all this may be a simple question but how can I put a delete character (Hex vale 0x7F) at the end of a CString tried every thing I can think.
The code is
chBcc = GetBcc(strPack);<br />
strPack.Insert(32, chBcc);
chBcc can be the delete character.
thank you
Ketil b
|
|
|
|
|
Anonymous wrote:
strPack.Insert(32, chBcc);
Does strPack.Insert(32, chBcc) not work? If not, have you stepped into the code to find out why?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|