|
I think that you actually want to use SetWindowOrgEx , this is the function that has the effect of shifting the origin.
|
|
|
|
|
I read an Nov. 2001 interview of Stanley Lippman, the VC++ architect, that mentioned future support for Winforms along the lines of C#/VB (RAD).
I further read an Feb. 2002 interview of Nick Hodapp, the VC++ proj. mgr., that (ominously in my view) did not seem to specifically mention support for Winforms/IDE/RAD/C++.
Does anyone (Chris Maunder?) have any idea how MS plans to move forward on this topic?
|
|
|
|
|
Anyone know how to do that ?
Thanks
Zindine
|
|
|
|
|
Hmm, I can't find an API. But that information can be found in the registry under HKLM\Hardware\...
However, I bet it would be different for each OS version.
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 creating a thread in the OnCreate function of a view
CDocument * pDoc = GetDocument();AfxBeginThread(RxDataProc, pDoc);
The simplified thread function looks like (don't be concerned about what it does, that's not the real problem)
UINT RxDataProc(LPVOID param){
CLOPCDoc* pDoc = (CLOPCDoc*)param;
ASSERT_VALID(pDoc);
pDoc->LoadConnParameters();
bool running = true;
while(running)
{
if(int result = ::WaitForSingleObject(g_evThreadEnd.m_hObject, 0) == WAIT_OBJECT_0)running = false;
else
{
try{
if ( !myFile.Open( pszFileName, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite ), &fileException ){
TRACE( "Can't open file %s, error = %u\n", pszFileName, fileException.m_cause );
}
CSerialPort port;
port.Open(pDoc->nComPort_DU, pDoc->nBps_DU, (CSerialPort::Parity)pDoc->nParity_DU,
pDoc->nDataBits_DU,(CSerialPort::StopBits)pDoc->nStopBits_DU,
(CSerialPort::FlowControl)pDoc->nFlowControl_DU);
char sRxBuf[23];
DWORD dwRead = port.Read(sRxBuf, 23);
UNUSED(dwRead);
myFile.SeekToEnd();
myFile.Write( sRxBuf, sizeof( sRxBuf ) );
myFile.Close();
port.Close();
}
catch(CSerialException* pEx){
TRACE(_T("Handle Exception, Message: %s\n"), pEx->GetErrorMessage());
pEx->Delete();
}
}
}
return 0;
}
Anyway, my problem is I am getting an access violation when the program runs and upon debugging I found that it is coming from accessing member variables of the Document class via pDoc.
I get no compile errors. What's the problem here?? Is it even possible to access member variables and functions from a thread??
|
|
|
|
|
It is perfectly possible to access member variables of your CDocument -derived object. The code seems fine to me, and I suspect the error must lie elsewhere. Possibilities:- the document is being
delete d prematurely in the main thread. LoadConnParameters needs to run in the context of the main thread rather than in the secondary (non UI) thread. You can easily check this out by moving the call to LoadConnParameters to the main thread (just before calling AfxBeginThread , for instance).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a bunch!
I put LoadConnParameters outside the thread and now it works fine.
Thanks again.
- Merle
|
|
|
|
|
Hi,
I'd like to know how to use the HTMLView Navigate2 method with HTML files that are contained as resources in the .exe in which the HTMLView is located. Anyone have some sample code? Something like:
Navigate2("res://??????")
Or something like this?
Thanks,
Aaron
|
|
|
|
|
You mean this???:
Navigate2(_T("D:\\MyPage.htm") ,NULL,NULL);
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
|
The syntax is res://sFile[/sType]/sID ( check MSDN / Internet development SDK for samples ).
|
|
|
|
|
I am looking for help in understanding how to have a parent dialog be made aware of button presses that occur from buttons that are pressed on the panes of a property sheet.
I already have code in the classes, for each of the property pages, that gets attention when each of these buttons is pressed. I have that code in the property page class becasue some information from the page controls needs to be gathered and then the parent dialog needs to know this information. The parent dialog uses this to change an edit control contents that is on the dialog outside the client area of the property sheet.
What is the method to report this information out to the parent dialog?
MIKE
|
|
|
|
|
This is far from standard, but you can try the following:- Go to the source code for your propery page and replicate the handler declaration in your property sheet (the message map stuff, you know).
- In
CYourPropertyPage::OnButtonClicked propagate the message at the end of the handler with GetParent()->SendMessage(WM_COMMAND,MAKEWPARAM(ID_BUTTON,BN_CLICKED),(LPARAM)m_hWnd) . - Do whatever you need to in
CYourPropertySheet:OnButtonClicked .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your reply. Your suggestion game me an idea to try. Instead of cloning the handler and the message table I can see (from a debuggger trace) that within the button handler of the property page I can use GetParentOwner() to get the CWnd* of the parent dialog. Using this
I can send a message right to the base dialog. I do have yet to work out just what message to send. I would like there to be a single handler in the base dialog for all of the various buttons on the proprety pages. Due to this I inclined to look into the WM_NOTIFY scheme or
to otherwise use the ON_REGISTERED_MESSAGE() macro mechanism inthe message map and make a custom message type via a registration with windows.
Mike
|
|
|
|
|
Hio.. im trying to move a button down like 10 pixels, but not having any luck..
CButton* pSelectBtn = (CButton*)GetDlgItem(IDC_CREATESELECTBTN);
CRect SelectRect;
pSelectBtn->GetWindowRect(SelectRect);
SelectRect.top +=10;
pSelectBtn->SetWindowPos(&wndTop, SelectRect.left, SelectRect.top, 0, 0, SWP_NOSIZE);
whenever i do this the button just dissapears.. if i change the flag to SWP_NOMOVE and set the width and height it will resize the button, but i just cant seem to move it.. even if you remove the 'SelectRect.top +=10;' the button still dissapears.. i have tried doing GetWindowRect, and then passing SetWindowPos(&wndTop, SelectRect.left, SelectRect.top, (SelectRect.right - SelectRect.left), (SelectRect.bottom - SelectRect.top), SWP_NOSIZE), and even then the button just dissapears..
i know its moving, but obviously im giving it the wrong left and top parameters.. any helP?
-dz
|
|
|
|
|
SetWindowPos positions are relative to the parent's client area and GetWindowRect returns a position on the screen.
Try doing something like...
....
pSelect ->GetWindowRect (SelectRect);
ScreenToClient (SelectRect);
....
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?
|
|
|
|
|
super sweet, thanks!
-dz
|
|
|
|
|
Use setwindowplacement...
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
When I use the classwizard to create a MFC class the constructors are protected. Why is this? My programs run if I move the constructor out into the public: section but I have this nagging feeling that something terrible will happen one day becasue of it. Could somebody shed a little light on this subject for me?
|
|
|
|
|
Some classes created by the MFC wizard (like for instance those derived from CView ) have their ctors protected by default because they are intended to be created by the framework dynamically, i.e. whithout knowing the exact type of the CView -derived class until runtime. This is accompished by means of CRunTimeClass objects:
CRuntimeClass* pRTClass;
...
CView* pView=(CView*)pRTClass->CreateObject(); This technique implements a design pattern commonly known as virtual constructor.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi all
I have been customizing overridden print methods like onPrepareDc() and print() etc. My programs work but my knowledge is still fuzzy.
My question is - can somebody please explain to me the definition and differences between
- windowExt
- viewportExt
- logical units
- dots per inch
and how these 4 things really interact when it comes to printing.
I have checked MFC's documentation and about 4 diff MFC books and the MIcrosoft site. Nobody comes out and defines these things, they all just talk about how to use them.
Any help appreciated
or just point me to some references please
IGeorgeI
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
Device Units / Coordinates:
Device units are the actual units of the device context. This would be pixels.
Logical Units / Coordinates:
Since different devices have different resolutions, windows allows programmers to define Logical units in order to make the graphics programming more device independant. Logical units are also called the page coordinate space. This allows the programmer to define the units that they would like to work with instead of pixels. For instance, say you are writing a landscaping program, you could define the base unit as 1/8 inch.
WindowExtent:
This is a value that indicates what units that you would like to work with.
ViewportExtent:
The size of the viewport that the WindowExtent will be mapped to. Say you wanted to make a mini-view of a document, you would set the WindowExtent to the size of the document regularly, and the Viewport extent to the size of the mini view. Then you use the same paint code, and you will have a mini-view of your document.
Dots / Inch:
This is the resolution of your printer or display device. Usually monitors aren't measured like this so I will explain printers. A fairly standard resolution for printers is 600 dpi, which is 600 dots / inch. You can think of this as 600 pixels / inch. If you left you DC that you received from your printer as the default, you would be painting each individual pixel, but since you set the window extent and the viewport extent, the logical or page coordinates get remapped to allow you to paitn your graphic on the entire page.
There is alot of information in MSDN and in Charles Petzolds Windows programming book.
|
|
|
|
|
Consider the following section of code:
int a = 10;
int* b;
Which of the following statements places the address of a in b. Remember, more than one of these options may be correct. In your response, explain which ones work and why, and also explain why the incorrect answers will not work. I want more than a listing of the syntax errors!
b = a;
b = &a;
b = *a;
*b = a;
&b = &a;
Loli10
|
|
|
|
|
|
Not quite. It's something that came up in lecture. My homework is writing a program.
Loli10
|
|
|
|