15,895,084 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 Iain Clarke, Warrior Programmer (Top 15 by date)
Iain Clarke, Warrior Programmer
4-Nov-15 4:36am
View
This question does not make a lot of sense. C# had forms. MFC has windows and dialogs. If you have a dialog box, and a graph control on it, then I am guessing you are adding a double click handler to your dialog box, when you should be adding a notify handler, with the notify code and control ID.
Without knowing what "graph" is, we can't really help you any more that that.
Do a search for ON_NOTIFY, and NM_DBLCLK, and some information about standard controls will show up for you.
Iain Clarke, Warrior Programmer
31-May-13 7:45am
View
Well, I can do VT_BYREF | VT_I4 to "connect" to a (..., ref int, ...) function, so the marshaller is clever enough there. Just VT_ARRAY | x means the marshaller has to package up a safearray with its contents to pass to the other end too.
My problem is that the marshaller does not "bring back" the array afterwards...
I have done some reading into MarshalAs which started to look hopeful, but that might be just for C# to c++ (ie, PInvoke), not COM to C#.
Iain.
Iain Clarke, Warrior Programmer
21-May-13 6:38am
View
You: "each value is a gray level from 0 to 255"... sounds like 1 byte to me!
As you have 1024 pixels, your data is already a multiple of 4, so I don't think you need padding. You might have the values in the BITMAPHEADER wrong? And maybe you're saying you;re using a palette, when your data is already in colour?
I'd start with a simple 16x16 array, with all colours being simple, and work up from there. If your 24 bit colour values are "backwards", then you might just have to copy them to another buffer, re-arranging them as you go.
Iain.
Iain Clarke, Warrior Programmer
20-May-13 4:58am
View
Didn't you say your data is 1 byte, and greyscale?
In which case, R=G=B!
But I think the confusion may be in how intel stores numbers:
0x12345678 stored in ram becomes: 78 56 34 12
Trust me, you can use COLORREF type and RGB macro for this.
Iain.
Iain Clarke, Warrior Programmer
15-May-13 3:40am
View
I guess you have a CDC of some sorts, and are doing SetPixel in a loop?
If so, throw the loop away, and do:
::SetDIBitsToDevice (*pDC, ...., &m_pBlockOfBytes, &m_bmiPrePreparedBitmapStructure, DIB_RGB_COLORS);
Your block of bytes is where your numerical values are - bytes 0-1024, followed by bytes 1040-2047, and so on. It's not quite the same as a 1040x1024 array, but it's equivalent.
You can also prepare your bitmap array in advance too:
m_pbmi = (BITMAPINFO *)malloc (sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
ZeroMemory (m_pbmi, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
m_pbmi->bmiHeader.... = ...;
for (int n = 0; n < 256; n++)
{
m_pbmi->bmiColors [n].rgbRed = n;
m_pbmi->bmiColors [n].rgbGreen = n;
m_pbmi->bmiColors [n].rgbBlue = n;
}
As I said before, this is a complex function, but powerful. Once you've done the initial setup work, you can just change one of your data bytes, invalidate your window, and in your paint / ondraw function, you can just call the one line setdibitstodevice function, and you're done!
It's MILES faster than 1 million setpixels.
Iain.
Iain Clarke, Warrior Programmer
15-May-13 3:01am
View
There's an example linked from the website I showed above, but I agree it's not very clear.
Unfortunately, any code I can paste in here belongs to previous customers, but I can recommend just looking at the msdn pages, and for BITMAPINFO structure too.
Iain Clarke, Warrior Programmer
25-Jan-13 5:19am
View
Have you read here: http://msdn.microsoft.com/en-us/library/bb432403(v=vs.85).aspx
It apparently is a bit obsolete now...
Iain.
Iain Clarke, Warrior Programmer
13-Sep-11 7:49am
View
If one of the solutions here helped you, you should "Accept" the solution so others will know it was a good one.
And then people like me will know that your question has been answered.
If they did not help, and you found out the answer yourself, then you should add a comment to your original question.
Glad CP helped you,
Iain
Iain Clarke, Warrior Programmer
23-Mar-11 10:05am
View
This does not actually help the user... Whether the different views are tabbed, or have a more proper window frame does not change his problem.
Iain.
ps, I would be a bit surprised to see a MDI classic program now, but tabbed documents are still MDI...
Iain Clarke, Warrior Programmer
23-Mar-11 7:29am
View
This is going to be a little hard to understand, but when you do, you'll go "ahah!!".
When you pass an object by value, the function gets a whole new object to play with - it's copied from the "original".
If you pass a pointer to an object, then the function gets a pointer to the original. If you make changes to the object in the function, then the original gets changed. Try experiment with this - make a function, taking a pointer to something simple, like a CPoint.
When you define a pointer to an object, you don't have to define the object. A pointer to anything is the same size. [99% true]. A pointer is just a memory location value. The compiler is nice, and makes sure you don't make easy mistakes, but that's all it is.
The problem with pointers, is that it is not all that difficult to make mistakes. People can set them to NULL, and so on.
References are just like pointers. They're just pointers in a fancy suit. It's just harder to make mistakes. You can't have NULL for example.
More than this, you'll need to go get a book - but I hope this has given you something to think about, and experiment with.
Iain.
A reference
Iain Clarke, Warrior Programmer
22-Mar-11 7:20am
View
Iain Clarke, Warrior Programmer - 19 mins ago
Have a look here: http://en.wikipedia.org/wiki/Circular_dependency
In short.
A depends on B.
B depends on C.
C depends on A.
I hope that helped,
Iain.
Iain Clarke, Warrior Programmer
22-Mar-11 7:00am
View
Deleted
Have a look here: http://en.wikipedia.org/wiki/Circular_dependency
In short.
A depends on B.
B depends on C.
C depends on A.
I hope that helped,
Iain.
Iain Clarke, Warrior Programmer
11-Mar-11 7:28am
View
This is a question, or maybe comment, not an answer.
Iain Clarke, Warrior Programmer
23-Aug-10 14:02pm
View
Pretty much any charting answer is "look at Cedric's control" !
You da chart guy!
Iain.
Iain Clarke, Warrior Programmer
9-Jul-10 9:52am
View
Reason for my vote of 5
Answers the question, and attempts to educate the questioner also
Show More