|
If you have a default printer on your system, you probably need to call
UpdatePrinterSelection(TRUE);
in your applications InitInstance() function. This will select he system wide default printer for your application as default. Then you will only need to do:
if (!AfxGetApp()->CreatePrinterDC(dc))
when you need a printer DC. Remove the SelectPrinter() line, as this is done for you in the UpdatePrinterSelection() call.
Roger Allen - Sonork 100.10016
If your dead and reading this, then you have no life!
|
|
|
|
|
Thanks a lot Roger Allen.
Murali.M
|
|
|
|
|
1.How do I access the onpaint(WM_PAINT message handler)of the main window from the child window. For ex.While loading an image from child to parent window,the overlap portion has to be repainted on the parent window.
2.Can I integrate VB codes with VC++ ? and how?
3.What is vb5addin.dll. and why it is needed? and how I will use it through my programme.
|
|
|
|
|
try GetParent()!
Hello World!
|
|
|
|
|
If i got you rite, you want to send the onpaint message to the parent window.
so what you do is,
get the HWND or CWnd* of the parent window and Invaidate() it.
This will redraw your parent window.
The World is getting smaller and so are the people.
|
|
|
|
|
is it possible to transfer a file through PSTN without an internet?
if it is possible can anyone send me the details?
thanx
|
|
|
|
|
you can do it using the telnet,
The World is getting smaller and so are the people.
|
|
|
|
|
I have done this long back, You use Hyperterminal to dial the target number, the target person should also start hyperterminal and configure his modem in a server mode,(you need to know the correct AT command of the modem for that) then you dial the no, after establishing the connection you can then transfer files across.
hope i aswered your question.
regards,
Prakash.
|
|
|
|
|
Here is a code to figure out timer0's frequency of 8254
(1)First,
llCountOfBegin=KeQueryPerformanceCounter(&llFreq);
wCount2=ReadCount8254(0);//read timer0 count
while (lCountINT8<500)//wCount2 is the current count,
//wCount1 the former count
{
wCount1=wCount2;
wCount2=ReadCount8254(0);
if(wCount2>wCount1)
lCountINT8++;
}
llCountOfEnd=KeQueryPerformanceCounter(&llFreq);
lTemp=(ULONG)(llCountOfEnd.QuadPart-llCountOfBegin.QuadPart);
(2)Then the frequency is
freq=lCountINT8*llFreq.lFrqForCmpCount/lTemp;
However, there is a problem. The frequency that is evaluated in this way is twice of the theoretic value When I write an initial count(lCount) into timer0's counter. The theoretic value is: 1,193,200/lCount.
My test env is windows2000/xp. Do you know the reason and how to solve this problem?
Thanks for your attention!
|
|
|
|
|
I am doing this in Win32 and I wonder how would you search for a specific numbers or strings.
|
|
|
|
|
Read my articles on iostreams. IMO you should always use the C++ standard library as a first port of call, although there is no reason not to use OS specific API's if they perform better or do what you want.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am looking for bitmap files that contain the following information headers: BITMAPCOREHEADER, BITMAPV4HEADER, BITMAPV5HEADER.
(Note: I have all the files with BITMAPINFOHEADER that I need)
If anyone knows of any bitmap files on the www that use the above headers, please let me know.
I would like to use them to test my code and creating them my self does not garantee that they are correct.
INTP
|
|
|
|
|
is there a way to convert String to string ?
I am using c++.net forms in the form.h file when i try to get the name of a file from the texbox and open it , i get an error.
it sayd it cant convert the typr _wchar to char !!!
i used
ifstream infile;
infile.open(fileName);
|
|
|
|
|
wchar is a wide string. you need to use wstring instead of string. You can also use _bstr_t to convert automagically between them, I think it's in comutils.h.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
thanks christian
can you write it as a code i am not so sure how to use _bstr_t
eg.
char me;
Char you;
is it then right to say
me = _bstr_t(you)
and can it be used for char arrays as well?
|
|
|
|
|
_bstr_t is a string wrapper that internally contains both a wide and a narrow string. It would treat a char as a char array of one. I would use it like this:
some COM function(BSTR myBSTR, BSTR * returnBSTR)
{
std::string s(dynamic_cast<char*>_bstr_t(myBSTR));
... use the string
*returnBSTR = _bstr_t(s.c_str()).detach();
}
The syntax is probably horribly wrong, it's 12 months since I did any serious C++, but certainly that is mostly right. My string is being passed a char * in it's constructor, which comes from a temporarily created _bstr_t. The cast to char* may not be necessary, the point is that _bstr_t will construct itself from the BSTR ( wide string ) and then it's operator char* will perform the conversion for you.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
calling IWebBrowser2->Stop() for an embedded browser control does what I need, except it makes the "stop loading" click you also hear when browsing / clicking a link normally.
Can I make this "mute" (only for my control, not globall for the system), or get the effect of Stop() without the noise?
Background:
I'm using the IE Browser control for custom data display.
I've abstracted the document handling in a small helper control. The caller can set a HTML document as template (typically containing headers, and style definitions/style sheet), and then append text to the Body element. When the template is not loaded, appending Text is deferred until the DocumentComplete event fires.
Without calling Stop(), DocumentComplete gets confused with frequent Navigate() calls (setting a new template before the previous loaded).
"Vierteile den, der sie Hure schimpft mit einem türkischen Säbel."
mlog || Agile Programming | doxygen
|
|
|
|
|
People on this message board did try to help me out with this before, I got frusterated and decided to leave it for a while, then come back to it, thinking it would be easier to fix.
I have a bitmap, representing 92 of the elements from the periodic table. each of these 92 elements must have a distinct colour (using r, g, b values). I also have a .txt file containing the element symbol, name, and each of the rgb values, in the format:
Hydrogen,H,1,49,0,0
...
When the user clicks on the bitmap, I obtain the r, g, b values at the point of the click, and use those values to determine which element the user clicked on.
So, here's the problem:
When the user clicks on Hydrogen, for example, with a colour setting of 16-bits, everything works fine. But, if i change the colour settings of my monitor to 24 or 32 bits, my program reports that the user clicked on the colour 51, 0, 0. I am using photoshop (new to using this) to edit the colours of my bitmap. Still working with the Hydrogen example, photoshop says that hydrogen is set to have the colour 51, 0, 0 (no matter what my colour settings are). So I did change the entry in my text file to reflect this colour, but when I run my program, it reports that it is, in fact 49,0,0 in 16-bit and 51,0,0 for 24 and 32 bit colour.
This is how I'm obtaining the colour in my code:
COLORREF crColourAtPoint = 0;
...
crColourAtPoint = GetPixel(memDC.m_hDC, pt.x, pt.y);
CString values;
values.Format("Red: %d\nGreen: %d\nBlue: %d", GetRValue(crColourAtPoint),
GetGValue(crColourAtPoint), GetBValue(crColourAtPoint));
AfxMessageBox(values);
|
|
|
|
|
I think you're going about this the wrong way ... why do you pick depending on the color ? Why can't you just pick depending on the pixel position ? i.e. when the user clicks on one particular element "space" you only need to check it the mouse is inside the "space" ?
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Either way, I'd still have to record a bunch of information, whether it be the location of each elements space, or the colour of the element.
A few months ago I had discussed different ways of doing this with a bunch of people on here, and after a few days of going through the different options, it was decided that the clickable bitmap approach would be the best option. So I did it that way. I'm just running into a problem when switching down to 16 bit colour, as I expected. I thought that just by switching my monitor settings to 16 bit, then re-colouring the bitmap, and putting the new colour values into my .txt file my problem would be solved. I figured that if I did it that way, the colour values would remain constant between 16 bit and 24/32 bit colour, but I was wrong.
I need to know whether I'm just selecting the wrong colours, or whether there's a way to determine from within my code what colour settings the user has for their monitor, or even if this problem is fixable or not.
|
|
|
|
|
I would agree with Maximilien in that there is a better way to go.
But first the problem you are experiencing is caused by the fact you are saving the image in photoshop as a full RGB color range of 24 bits. When you go to display it on a system that cannot support that color range, the colors are down converted to the displays setting range (16 bit in this case). The solution is to save the image in Photoshop using smaller palatte. Try using Image->Mode->Index color on the menu and save to a 256 color system palatte to get you image colors downselected.
Back to your method... I would suggest you look at an article submitted last month here in CodeProject. I can't remember the name of the author but the program name was something like "Periodic Table" or PTE table.. where the author used some very good techniques to accomplish the same task of locating the periodic table element from the mouse position.
Hope this helps.
Art
|
|
|
|
|
Art Friesz wrote:
using Image->Mode->Index color on the menu and save to a 256 color system palatte
I am using indexed colour in photoshop.
Art Friesz wrote:
would suggest you look at an article submitted last month here in CodeProject. I can't remember the name of the author but the program name was something like "Periodic Table" or PTE table
This article was written by one of the guys that was helping me before, back in september. He started that article because I was asking about it back then. Seeing as I had never done anything with colours/bmp's in my applications before, I ended up needing quite a bit of help, as i guess I still do.
|
|
|
|
|
OK, if it were me and I just wanted to get this problem solved I would do one of the following:
Option 1) Compare on a range of RGB values. Example: allow a match of the RGB color provided in the txt file if the mouse pickuped a value within say 5 of each of the RGB values. In other words Hydrogen would be matched if the mouse picked up a R value between 51-5=46 and 51+5=56 and G and B was between 0 and 5.
or Option 2) (the preferred way)
Change your text file to include the percentages of the grid they occupy in the image and then pick up the mouse position on the window and convert it to percentage of the window width and height, then match the point in the rectange:
(Element Name, Element symbol, atomic no., x1,x2,y1,y2)
Example: text file would look like this:
Hydrogen,H,1,0,6,0,8
Helium,He,2,0,6,10,18
...
When you read in the txt file use the x1, x2.. for the coordinates in a CRect. Use CRect::PtInRect()to look for a match.
Art
|
|
|
|
|
I used your idea for option 1... that fixed my problem. thank you very much!
|
|
|
|
|
Windows remaps colours to best match the available palette. 4- and 8-bit modes are palettized; you can specify the palette you want to use by calling RealizePalette. You should do this in response to a WM_QUERYNEWPALETTE or WM_PALETTECHANGED message.
In 16-bit mode, the available range of colours is typically limited to 5 bits per pixel for red and blue colour information and either 5 or 6 bits per pixel for green colour information. The colour you request is mapped onto the bits available; when you request the colour of the pixel, the value is mapped back onto the 0 to 255 range. This conversion can be subject to rounding errors.
If we say that Red is limited to 5 bits of representation, that gives us values 0 to 31. Mapping your 51 in the 0-to-255 to this range gives 6.375, rounded down to 6. When getting the pixel colour, the actual 6 in the 5 bit world now becomes 48 in the 8 bit world. I assume that Windows isn't doing a direct mathematical conversion, probably factoring gamma into the equation as well, which leads to the specified 49.
Anyway, you can't rely on the colour retrieved from GetPixel being the colour you set. It's better to work with areas of an image than with colours, if possible. Alternatively, work directly with the original bitmap, rather than the on-screen representation of it.
|
|
|
|
|