15,907,497 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Tanveer Asim (Top 25 by date)
Tanveer Asim
1-Dec-14 3:08am
View
After i found that one image is loading then i opened my images in Paint and saved as 24bit Bitmap, now they are loading in LoadImage. And i am able to print using StretchBlt as you demonstrated in your example. Thanks for help.
Tanveer Asim
1-Dec-14 3:06am
View
After i found that one image is loading then i opened my images in Paint and saved as 24bit Bitmap, now they are loading in LoadImage. And i am able to print using StretchBlt
Tanveer Asim
27-Nov-14 1:32am
View
@Jochen i tried different images and one of them is loaded and if i open and save my image as 24 bit image then it is loaded in ImageLoad as well.i will try with rest of code now.
Tanveer Asim
27-Nov-14 1:30am
View
@enhzflep even with this code i was facing same problem of loading image. As you and @Jochen mentioned i downloaded different images from internet and tried them. One of them was loaded in ImageLoad, later on i opened my image in paint and saved it as 24bit bmp and it is loaded as well. Now i will try to print. Thanks for your help
Tanveer Asim
25-Nov-14 15:07pm
View
Initially i started with same concept to accomplish task with CDC but all knowledge base article examples that i found about CDC they were working with GUI and somewhere i read as well that if you have to work with print dialogues and gui then CDC is utilized and if you have to create context manually then HDC is is the option. I don't know how correct it is.
Tanveer Asim
25-Nov-14 14:35pm
View
I can open image in viewer, display on screen also print using cdc. i think the image is not currupt may be some other issue. I will try with some other images.
Tanveer Asim
25-Nov-14 13:56pm
View
i don't want to do it with CDC because i don't want to show any GUI. I wrote this code only to show you that i am able to print with GUI by this code
Tanveer Asim
25-Nov-14 13:54pm
View
yes GetLastError is not giving any error. I am not loading any other image before this call.
Is it possible that there is conflict due to multiple included header files? During testing multiple options i included many header files.
Tanveer Asim
25-Nov-14 13:27pm
View
Jochen actually wrote this code to show that what is working in GUI mode.
LoadImage is the first call that fails it returned value is null and GetLastError returns 0.
About hidden window, can i use this solution in class library project. Because i am working on a dll that will be utilized by another component. if it works then i can go for any solution for initial release. Please suggest how i can do that
Tanveer Asim
25-Nov-14 7:13am
View
yes you are right. But at that time i am using CBitmap that can be attached to CDC and HDC expects HBITMAP. Following code works fine
CImage frontImage;
frontImage.Load(_T("C:\\Front.bmp"));
CBITMAP bitmap;
bitmap.Attach(frontImage.Detach());
BITMAP bm;
bitmap.GetBitmap(&bm);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap *pBmp = memDC.SelectObject(&bitmap);
int w = bm.bmWidth;
Tanveer Asim
25-Nov-14 5:50am
View
initially i printed with gui, displayed image and printed using CDC
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap *pBmp = memDC.SelectObject(&bitmap);
it worked fine. i am having issues with HDC. I will try also by using XPS as default
Tanveer Asim
25-Nov-14 5:46am
View
0 is returned by GetLastError, In GUI mode i used CDC and selecting bmp worked fine
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap *pBmp = memDC.SelectObject(&bitmap);
Tanveer Asim
25-Nov-14 5:20am
View
@Jochen BitBlt is returning 1 but i checked LoadImage retuns null HBITMAP.As you said as well actually the problem is with LoadImage, i am not sure what can be the alternative to this
Tanveer Asim
25-Nov-14 5:06am
View
Following is my code and logo is always null and file is available on specified location
HBITMAP logo = (HBITMAP)LoadImage(NULL, szFileName, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
Tanveer Asim
25-Nov-14 4:44am
View
@enhzflep i tried both solutions, in first with gdiplus it is printing blank. Then i tried 2nd, here it is printing red border but no image. i tried to check error by GetLastError() but it is 0 every time. can i check at any place that image is loaded to hbitmap or no and is attached to hdc as well?
Tanveer Asim
25-Nov-14 2:06am
View
Thanks a lot, i am trying both options
Tanveer Asim
24-Nov-14 13:11pm
View
and what about SelectObject(memHDC, frontBitmap). if there is image in fronBitmap then it should attach image to memHDC? currently it has no effect
Tanveer Asim
24-Nov-14 12:30pm
View
I have added another option to my question that i tried. Can you please have a look
Tanveer Asim
24-Nov-14 12:30pm
View
yes only CreateDC is successfully and creates dc, other two run without any error. IN select object nothing is assigned to dc and same is with BitBlt
Tanveer Asim
24-Nov-14 12:14pm
View
thanks jochen for your help. I tried LoadImage with "LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE"but every time result is same. is there any other option other than LoadImage. I don't have good enough experience in vc++.
Tanveer Asim
24-Nov-14 11:46am
View
I printed same image with GUI application. Image was displayed on form and then i printed using CDC. I am developing a class library project and don't want to display any GUI.
Tanveer Asim
24-Nov-14 11:42am
View
yes you are right but i tried other as well just to try
Tanveer Asim
24-Nov-14 5:42am
View
i tried with all options like back/ forward slash, single double slash
Tanveer Asim
24-Nov-14 3:37am
View
sorry i think i cannot attach pictures here
Tanveer Asim
24-Nov-14 3:35am
View
GetObject has no effect, it do not fetch image. Also LoadImage is returning non null value but it is not valid value and GetLastError returns 0 but. Please view the attached image
Show More