|
Hello,
Do you know what it means logical units at the help (MSDN) of StretchBlt ?
I found problem to define to origin at this function...
Thanks!
|
|
|
|
|
you better post the link I got the documentation about Windows GDI .
Without knowing anything I guess origin (0,0) is the top left corner of the window,
and logical coordinates are pixels.
|
|
|
|
|
Hanan888 wrote: logical coordinates are pixels.
Only in MM_TEXT mode, see here[^]
Graham
Librarians rule, Ook!
|
|
|
|
|
TalSt wrote: Do you know what it means logical units at the help (MSDN) of StretchBlt ?
This[^] explains it
Graham
Librarians rule, Ook!
|
|
|
|
|
Do you want to print any thing?
|
|
|
|
|
Hello,
I want to draw a BYTE* array on the screen by creating a bitmap and use StrechBlt function.
The problem was that the origin point was not (top, left) but (bottom, left).
I thought that it may be the StrechBlt function but finally I found that the problem is the creation of the bitmap from the BYTE* array.
The fix is:
m_bitmapInfo.bmiHeader.biHeight = -m_nImageHeight; // top-down DIB
The height should be -.
// Populate bitmapinfo header
m_bitmapInfo.bmiHeader.biSize = m_nBitmapInfoSize;
m_bitmapInfo.bmiHeader.biWidth = m_nImageWidth;
m_bitmapInfo.bmiHeader.biHeight = -m_nImageHeight; // top-down DIB
m_bitmapInfo.bmiHeader.biPlanes = 1;
m_bitmapInfo.bmiHeader.biBitCount = BPP;
m_bitmapInfo.bmiHeader.biSizeImage = m_nImageSize;
m_bitmapInfo.bmiHeader.biCompression = BI_RGB;
m_bitmapInfo.bmiHeader.biClrImportant = 0;
m_bitmapInfo.bmiHeader.biClrUsed = 0;
m_bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
m_bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
Thanks for all!
|
|
|
|
|
Is there a reason for using braces if they are not part of a condition or loop? For example:
cameraCollection->Item(0, &camera);
{ //extra code...
}
In this example, will it make a difference if I take out the braces? if it does, why?
Also, I have a sample code with no braces in the for loops? I thought braces were required, but the code compiles and does what it is supposed to do.
Example:
for(int y=0; y<288; y++)
for(int x=0; x<353; x++)
brightnessSum+=frameBuffer[x+353*y];
modified on Monday, June 2, 2008 9:08 AM
|
|
|
|
|
I use them for "local" logical section in a function/method to keep variable close to what they do.
adding braces does not make a difference UNLESS you define a variable in the scope of the braces and either try to use it after or forgetting that you used it before, it can be confusing to you.
int myInt = 0;
{
int myint = 1;
}
cout << myInt;
This signature was proudly tested on animals.
|
|
|
|
|
Queeny wrote: In this example, will it make a difference if I take out the braces?
No. If you had any variables declared within the braces, they would go out of scope at the closing brace.
Queeny wrote: Also, I have a sample code with no braces in the for loops? I thought braces were required, but the code compiles and does what it is supposed to do.
for /while /if statements will use the next statement (i.e., single) if no braces are present. The following statements are equivalent:
for(int x=0; x<353; x++)
{
brightnessSum+=frameBuffer[x+353*y];
}
for(int x=0; x<353; x++)
brightnessSum+=frameBuffer[x+353*y];
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Queeny wrote: Is there a reason for using braces if they are not part of a condition or loop? For example:
Yes - for finer control of the construction and destruction of objects. For example:
{
CMyHeavyweight myobjObject;
myobjObject.DoYerThang( true );
}
Even if the object is not too heavyweight, you may have a reason to want/need to limit the time it exists because it manages some shared resource(s). Yes, this is usually a sign of bad design, but you may be using a pre-existing library that you have no control over.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I just want to add one more point. Its always recommenced, in "Maintenance" point of view. I'm taking "if" as an e.g.. If the "if" block is a single line, braces are not necessary.
But in future if someone(especially beginners) needs to add another line to the "if" body, chances are lot to forget to put the braces which will end up in trouble. For instance,
if( bFailed )
statement1;
Bugfix Statement1;
It won't occur often. But still a good practice.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
My thoughts exactly.
I've fell victim to that enough times that it's become common practice for me to always include them, in case I come back later and add to it.
Good advice.
|
|
|
|
|
No if your loop has statement you dont need to use of them however its better you use of them and for declare local variables if you have same name for global variables you must be use of them and ....
|
|
|
|
|
Hello,
I am making dll.Earlier the dll was being made.But suddenly the dll is not been made .I can see .dll file in the directory .But when I try to use it with a client the compiler says .dll is corrupt.
When I am making the dll I get 36 warnings and a message
Creating library Debug/BaseClassesDll.lib and object
Debug/BaseClassesDll.exp
What must be wrong?
Pritha
|
|
|
|
|
I have seen this message when the client was linking with the DLL. You need to link with the .LIB, which was created at the same time as the DLL. (The DLL still needs to be present, however.)
|
|
|
|
|
Hello,
Thanks for your reply.
I am not able to make the dll.When I make the dll I can see a .dll file the directory but when I link the file with the client project.the compiler says that the dll is corrupt.
Pritha
|
|
|
|
|
As I said in the first reply, you need to link with the .LIB.
More explicitly (on Visual studio 2005):
1. Click the Project menu.
2. Select your project's Properties.
3. Select "Configuration Properties".
4. Select "Linker".
5. Select "Input".
6. For the entry "Additional Dependencies", enter the name of the .LIB file (not the .DLL file).
7. Click OK.
The linker is expecting to find the .LIB file, but when it sees a .DLL file it thinks it's corrupt. (I agree it should say something more helpful, like, "Dude, where's my library?")
|
|
|
|
|
Did you recompile your project and did you import lib file to program?
|
|
|
|
|
I have 7 child dialogs, & a parent dialog. From parent dialog, I call 1st child, on the child dlg's buttons child sends message to the parent. Among that one message is to update the object in parent which is working fine. The second message is to hide that child and show another child dialog.
I have added method for the message :
afx_msg LRESULT DataEntryDialog::OnSHOW_NEXT_VIEW(WPARAM wparam, LPARAM lparam) {
}
In child1 :
in .h the events are declared as
enum
{
BASE = WM_USER,
CHANGED_DS, SHOW_NEXT_VIEW,
};
void CPage1Dlg::TellParent()
{
this->CRHPostMessageToParent(CHANGED_DS, (int)&deptStock);
this->ShowWindow(false);
CRHPostMessageToParent(SHOW_NEXT_VIEW, 2);
}
In parent:
Childs are created as below in OnInitDialog():
CRect rect(4, 2, 5,2);
CPoint point(0, 10);
childPage1.CRHCreateGenericChildDialog(this, &rect,0, NULL);
childPage1.SetDeptStock(deptStock);
rect += point;
childPage2.CRHCreateGenericChildDialog(this, &rect, 1, NULL);
childPage2.ShowWindow(false);
childVisible = 1;
afx_msg LRESULT DataEntryDialog::OnCHANGED_DS(WPARAM wparam, LPARAM lparam)
{
deptStock = (DeptStock&)lparam;
AfxMessageBox(_T("Dept Stock Updated"));
return 0;
}
afx_msg LRESULT DataEntryDialog::OnSHOW_NEXT_VIEW(WPARAM wparam, LPARAM lparam) {
int childView = (int)lparam;
AfxMessageBox(childView);
if (childView ==2) {
childPage2.SetDeptStock(deptStock);
childPage2.ShowWindow(true);
childVisible = 2;
}
return 0;
}
Any guidance on the above is highly appreciated.
Thanks
Terry
|
|
|
|
|
A lot of dialogs opened in one program is bad style and is confusing the programer and user so you should avoid it.
For communication is messaging between windows and dialogs suitable. Do it via PostMessage to avoid blocking.
For the data you better use one global object so everywhere is the same data. Then you only need to post the message to every open window/dialog that data is changed. Please believe me: make a array of HWND!!!
Greetings from Germany
|
|
|
|
|
Thanks KarstenK,
KarstenK wrote: Please believe me: make a array of HWND!!!
I am gonna make an array of CDialog & place each child dialog in it. Currectly, I am just checking it with 2 dialogs. Can you give some helpline of how to do with PostMessage. The
this->CRHPostMessageToParent(CHANGED_DS, (int)&deptStock); in return calls PostMessage by passing the childDialogId as WPAram
void CRHGenericChildDialog::CRHPostMessageToParent(UINT message, LPARAM lParam)
{
CRHpParent->PostMessage(message, CRHId, lParam);
}
Thanks
Terry
|
|
|
|
|
Trupti Mehta wrote: I have 7 child dialogs, & a parent dialog. From parent dialog, I call 1st child, on the child dlg's buttons child sends message to the parent. Among that one message is to update the object in parent which is working fine. The second message is to hide that child and show another child dialog.
Sounds like you need a property sheet wizard.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Terry,
So you have one parent dialog and 7 child dialogs. At first one of your child dialog will be displayed and if you click one button in child dialog, that child should be closed and next child dialog should be shown until all child dialog finishes. Is that your requirement?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Yes, want to hide 1 child and show other child. But I want this to be controlled programmatically as the child dialogs need not be in series. I mean after child3, on some basis child5, or child7 or child3 should come respectively.
I work on WinCE5 for a specific device and it doesn't support Property Sheets. WinCe supports, but that device's SDK doesn't support. So, I got to work out manually only.
Thanks
Terry
|
|
|
|
|
Terry,
I hope in your parent dialog, you're creating instance of child dialog and shows it by calling DoModel() .
Instead of child dialog sending message to parent, just close the child dialog by calling EndDialog() function. In the EndDialog() you can give a parameter which will be returned by the DoModel() function. So by checking the return code of ChildDialog.DoModel() , you can show next dialog. For instance,
void CParentDialog::ShowChildDialog()
{
CDialogDlg ChildDialog;
if( SHOW_NEXT_DIALOG == ChildDialog.DoModal())
{
}
}
void ChildDialog::OnNextDialog()
{
EndDialog( SHOW_NEXT_DIALOG );
}
Here in the e.g. if the DoModel() returns SHOW_NEXT_DIALOG, then its the request to show next dialog.
Just try this. Just let me know if you've more issues.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|