|
I'm using a CButton with the BS_BITMAP flag to draw a simple bitmap button.
I load the bitmap like this :
m_hBitmap = (HBITMAP) ::LoadImage(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_MY_BITMAP ),
IMAGE_BITMAP, 20, 18, LR_LOADMAP3DCOLORS );
to draw it "transparent" on the button.
and set the bitmap like :
m_Button.SetBitmap( m_hBitmap );
This works well, EXCEPT when the button is disabled; when enabled, the transparent part is "transparent", and the non-transparent part display nicelly.
When the button is disabled, the WHOLE bitmap is drawn as a dark gray rectangle.
Is there a solution to that ? I would like the disable state ( that is computed automatically ) look like what disabled buttons on toolbars look like.
Also, The LoadImage with the LR_LOADMAP3DCOLOR flag seems to be working on Win2K, but when I try my application on WinXP the color substitution does not seem to be working fine, the bitmap background is not the same as the button color.
Is there a known issue with LoadImage on XP or with BS_BITMAP ?
Thank you all.
Max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote: Is there a solution to that ?
What about DrawState(..., DST_BITMAP | DSS_DISABLED) ?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'm have a problem using the Win32 WriteConsole() function. It's just printing random characters, but I'm not getting any compiler errors. Can you take a look?
Client code:
<br />
MainWindowManagement MainConsole;<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
MainConsole.SwitchBuffers(1);<br />
MainConsole.WriteStreamBuffer1<<"It dosen't work!\n";<br />
MainConsole.WriteStreamBuffer2<<"No sh*t!\n";<br />
MainConsole.WriteStreamToBuffer(1);<br />
MainConsole.SetBufferCursorPos(2, 20, 20);<br />
MainConsole.WriteStreamToBuffer(2);<br />
MainConsole.SwitchBuffers(2);<br />
cin.get();<br />
<br />
return 0;<br />
}<br />
Specification file for higher level class (directly below):
<br />
class MainWindowManagement<br />
{<br />
public:<br />
MainWindowManagement();
MainWindowManagement(string NewWindowTitle);
void WriteStreamToBuffer(int BufferNum); :sigh:<br />
void SwitchBuffers(int BufferNum);
void SetWindowFillColor(PrintColorType NewFillColor);
void SetBufferTextColor(int BufferNum, PrintColorType NewTextColorFore, PrintColorType NewTextColorBack);
void SetBufferCursorPos(int BufferNum, int NewX, int NewY);<br />
void SetWindowTitle(string NewWindowTitle);
void SetWindowSize(int NewX, int NewY);
void SetBufferSize(int NewX, int NewY);
string ReturnCurrentWindowTitle() const;<br />
PrintColorType ReturnCurrentFillColor() const;<br />
PrintColorType ReturnCurrentTextColor() const;<br />
stringstream WriteStreamBuffer1;
stringstream WriteStreamBuffer2;
protected:<br />
MainWindowSpecs ConsoleBuffer1;<br />
MainWindowSpecs ConsoleBuffer2;<br />
Win32WindowInfo MainConsoleWindowInfo;<br />
private:<br />
int CurrentlyActiveBuffer;<br />
};<br />
Upper level write function:
<br />
void MainWindowManagement::WriteStreamToBuffer(int BufferNum)<br />
{<br />
switch(BufferNum)<br />
{<br />
case 1 : ConsoleBuffer1.WriteBuffer(WriteStreamBuffer1);<br />
break;<br />
case 2 : ConsoleBuffer2.WriteBuffer(WriteStreamBuffer2);<br />
break;<br />
default : cerr<<"Client error. Invalid buffer number [1,2]."<<endl;<br />
break;<br />
}<br />
}<br />
Specification file for lower level class:
<br />
class MainWindowSpecs<br />
{<br />
public:<br />
MainWindowSpecs();
Win32StandardHandles ReturnHandles() const;
bool ReturnHandleErrorState() const;
void WriteBuffer(stringstream &TextToWrite);
void RefreshHandles();
void SetBufferInfo(int NewXCord, int NewYCord, PrintColorType ForeColor, PrintColorType BackColor, SetBufferType BufferAction);
void RefreshBufferInfo();
void SetToActiveBuffer();
CONSOLE_SCREEN_BUFFER_INFO ReturnConsoleBufInfo();
protected:<br />
private:<br />
int SetBufferInfoSetFont(PrintColorType ForeColorToSet, PrintColorType BackColorToSet);
bool StdHandleErrorState;
Win32StandardHandles StandardHandles;<br />
CONSOLE_SCREEN_BUFFER_INFO ConsoleBufInfo;<br />
};<br />
The lower level WriteBuffer() function:
<br />
void MainWindowSpecs::WriteBuffer(stringstream &TextToWrite)<br />
{<br />
DWORD NumCharsWritten;<br />
string Text;<br />
<br />
Text = TextToWrite.str();<br />
<br />
WriteConsole(StandardHandles.hOut, &TextToWrite, Text.length(), &NumCharsWritten, NULL); :mad:<br />
if(Text.length() != NumCharsWritten)<br />
cerr<<"All characters were not written."<<endl;<br />
}<br />
|
|
|
|
|
CoffeeAddict19 wrote: WriteConsole(StandardHandles.hOut, &TextToWrite, Text.length(), &NumCharsWritten, NULL);
Does this output correctly:
WriteConsole(StandardHandles.hOut, "Hello World", 11, &NumCharsWritten, NULL);
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Yes it does. It still doesn't print out the stream when I switch it back to the origional code though.
|
|
|
|
|
In the WriteBuffer() method, does TextToWrite and Text contain the correct value?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello. I'm a absolute beginner at programming, but have a final class project that I'd like to begin working on nice and early. What I'd like to build is a Visual C++ program that will:
1. Take user input from a windows gui (text boxes, drop down menus, etc.)
2. Insert the input into the appropriate locations in existing html templates
3. Create new html pages based on the templates that have the users input added
4. Save the page(s) within a folder named something the user chooses, and have this folder located in a "projects" or "websites" directory where they can then access the folders/files and upload them to their server.
During this process the existing templates should not be overwritten either.
I've been able to create a very basic html page from console input using <ofstream> and "getline", but it requires mixing all the html tags with the c++ in the .cpp file. It's just messy and cumbersome. I know there must be a more efficient and elegant way of doing this that keeps the html separate from the c++, but at my beginner level I just don't know where to start. Hopefully someone here will have some insight and can give me some tips.
Thanks in advance.
-- modified at 15:37 Tuesday 13th June, 2006
|
|
|
|
|
Have you learned about SDI and/or MDI document view architecture yet?
There are several classes that deal with this.
Document Templates:
- CSingleDocTemplate
- CMultiDocTemplate
Views:
- CRichEditView (CRichEdit)
- CEditView (CEdit)
- CHtmlView (WebBrowser control)
Using, for example, the CRichEditView class you can open a file (text) regardless of the extension (.txt,.html,.xml), and load the file in the view. You can then edit it and "save as" a different filename.
mytmpl.html --> index.html
Using the CDocument class you can programatically save the document as a different name. I wouldn't get too far a head of the class though. You may be learning this near the end of the class anyway.
Mark
|
|
|
|
|
Hi want to know how to open a txt file in NotePad.exe using a button in my C++ app
and i want to know how can i read the current time/date and put them in a CString
Thans
|
|
|
|
|
Take a look at ShellExecute() for launching programs.
ShellExecute(NULL, "open", "mytest.txt", NULL, NULL, SW_SHOWDEFAULT);
Look at CTime class for data and time functions. An example of how you could use it:
CTime curtime = CTime::GetCurrentTime();
CString s = curtime.Format("%m/%d/%y %H:%M:%S p");
Mark
-- modified at 17:40 Tuesday 13th June, 2006
|
|
|
|
|
|
Mahhouraaaaaa wrote: Hi want to know how to open a txt file in NotePad.exe using a button in my C++ app
and i want to know how can i read the current time/date and put them in a CString
See CreateProcess(...) API
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hi !!!
I have new forum.
If you want you can register you at this link:
http://cppmasters.iphpbb.com
I take everyone in my forum !!!
Thanks.
-:KNOX:-
|
|
|
|
|
hello i want to write some lines into a Cfile ( text file ) but i cant create a new line using "\n" what should i do ...
i think i must search for the VbCrlf equivalent in C++
thanx for your help
|
|
|
|
|
|
Thank youuuuuuuuuuuuuuuuuuuuuuuuuuuuuu !!!!!!!!!!!!!
|
|
|
|
|
Mahhouraaaaaa wrote: youuuuuuuuuuuuuuuuuuuuuuuuuuuuuu !!!!!!!!!!!!!
Mahhouraaaaaa
Is there any problem in keyboard???
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
consider the following declaration on top of a.cpp
#include "mydefines.h"
const GUID FAR DetectionGuids[] =
{
// GUID 1
{ 0x4C4089A5, 0x7705, 0x9999, {0x11, 0x15, 0x20, 0x80, 0x9F, 0xa2, 0xa4, 0x94} } ,
// Add new GUID here
};
inside mydefines.h
I have
DEFINE_GUID(GUID_CLASS_CUSTOM, 0x44C4089A5, 0x7705, 0x9999, 0x11, 0x15, 0x20, 0x80, 0x9F, 0xa2, 0xa4, 0x94);
Now the above declaration shows a compiler error when i try
const GUID FAR DetectionGuids[] =
{
// GUID 1
GUID_CLASS_CUSTOM
// Add new GUID here
};
it gives me a message saying that it cannot convert from const struct _GUID to unsigned long
Any ideas ?
|
|
|
|
|
Hi
I have 2 PCs on a network (with shared hard drives, but not mapped). I wish to access the hard drive of Machine_2 from Machine_1 from within my Visual C app - can this be done without mapping the hard drives?
From Machine_1, I have tried opening "\\Machine_2\C\MyFolder\MyFile.txt", but I am unable to locate the file - am I doing something wrong, or this simply cannot be done?
Hope someone out there can help!
Thanks
Mike
|
|
|
|
|
69 Bay wrote: can this be done without mapping the hard drives?
Certainly, just use UNC.
69 Bay wrote: From Machine_1, I have tried opening "\\Machine_2\C\MyFolder\MyFile.txt", but I am unable to locate the file - am I doing something wrong, or this simply cannot be done?
What does the actual code snippet look like? Shouldn't that be C$ instead (assuming you are wanting to go through the administrative share)?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks for looking
I am experimenting at the moment and using :
FILE *fMyFile;
fMyFile = fopen("\\\\Machine_2\\C\\MyFolder\\MyFile.txt", "r");
if(fMyFile!=NULL)
fclose(fMyFile);
Each time I try this, fMyFile comes back as NULL !
Thanks again
Mike
|
|
|
|
|
69 Bay wrote: fMyFile = fopen("\\\\Machine_2\\C\\MyFolder\\MyFile.txt", "r");
...
Each time I try this, fMyFile comes back as NULL !
Because you are not using C$ like I mentioned, unless you actually have a share on Machine_2 named C.
What is the value of errno when fopen() fails?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi
I am a d**khead!
I just realised that the shared hard drive on Machine_2 was not shared as "C", but as "Mikes C"
Changing my app to this has got it working!
Thanks for your help
I will check more thoroughly before asking again!
Mike
|
|
|
|
|
If Machine_2 is not "resolveable" then this will fail.
You can put the entry in your "HOSTS" file (Not really ideal)
or
You can put an entry in your domain's DNS server(s) and make sure it is the first DNS server the machines hit and "forward" unresolveable requests to outside DNS servers for those non-intranet thingy's like yahoo.com, msn.com, etc... (preferable for deployments as changing server IP's simply requires a change in the DNS entry at the server(s))
or
put the IP directly in place of the computer name in the UNC path (best for testing)
\\192.168.50.50\C\MyFolder\MyFile.txt
-- modified at 12:09 Tuesday 13th June, 2006
Also, don't forget about the "rights" issues that come into play
|
|
|
|
|
Hi
I am a d**khead!
I just realised that the shared hard drive on Machine_2 was not shared as "C", but as "Mikes C"
Changing my app to this has got it working!
Thanks for your help
I will check more thoroughly before asking again!
Mike
|
|
|
|
|