|
ok, now it works.... almost!
I want to change the background, but the cde doesn't change the background:
void CWallpaperDlg::OnButton1()
{
CoInitialize(NULL);
HRESULT hr;
IActiveDesktop *pActiveDesktop;
//Create an instance of the Active Desktop
hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
IID_IActiveDesktop, (void**)&pActiveDesktop);
if(SUCCEEDED(hr))
{
pActiveDesktop->SetWallpaper((LPCWSTR)"C:\\Mina dokument\\Mina bilder\\eros15.gif", 0);
pActiveDesktop->ApplyChanges(AD_APPLY_ALL);
}
else
{
AfxMessageBox("Error o Error");
}
// Call the Release method
pActiveDesktop->Release();
CoUninitialize();
}
------------------------------------
<b><I><B>Rickard Andersson</I></B></b>, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
|
Hello,
Anybody knows how can I catch the Refresh Event using the BHO.
when the user press F5 or selects refresh from the broswer menu.
and I don't mean the DocumentComplete Event.
thanks,
|
|
|
|
|
Hi,
is it possible to change the size(thickness) of an edge drawn with a call
to the DrawEdge () function ?
I tried diferent methods, like changing the size of the border with the SystemParamterInfo
(), but it didn't work.
Maybe, selecting another pen ? How can i do that ?
Cheers,
Lion.
|
|
|
|
|
You can't. It's only used to draw simple pre-defined borders, and it doesn't use any pens. You could just use CDC::Rectangle() with a thick pen and a null brush.
Simon
"The more I learn, the more I realize I don't know" - Colin Davies
Sonork ID 100.10024
|
|
|
|
|
Anyone care to tell me what messages I should handle in the dialog when someone is sizing with the gripper on a status bar...???
Merci buckets!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I'm cloning notepad for windows, and i'm having trouble figuring out the Select all command. is there a message i can just send for that, and what is it, or is more complex code necessary?
|
|
|
|
|
::SendMessage(hWndEdit, EM_SETSEL, 0, -1);
The 0 is the start position, and the -1 is the end position. Because it is -1, this tells the window to select all of the text in the edit control.
|
|
|
|
|
If you are using MFC CEdit then check
CEdit::SetSel member function
Atul
Sonork 100.13714 netdiva
|
|
|
|
|
I'm looking for C++ code that compress Null-terminated string to minimum bytes.
The string has between 1 and 50 characters.
Thanks in advance
Didi
|
|
|
|
|
If it's only for 1 to 50 characters why compress...?
Anyways...each character uses 1 byte...but normal english requires only decimal 33 to 126 ascii.
126 - 33 = 93...which is not even close to 255, the maximum value that can fit into one byte.
11111111=255
01111111=127
00111111=63, no good!
from the above you can see that by using only the ascii characters in this range you can knock off one bit on each character, 8 characters later...thats one byte saved.
If you don't need case and some of the funny characters you could further shave off another bit, saving even more memory.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Thanx HockeyDude,
I forgot to say that the string has uppercase letters only and no special characters except underscore. (f.e MY_NAME_IS_DD)
do you have any idea when I can find C++ code that imlements what you described ?
Thanx
DD
|
|
|
|
|
I don't actually, but it sounds like a interesting project to undertake when time permits.
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
What is wrong with this?
CPaintDC dc(this);
Graphics graphics(dc.m_hDC);
Bitmap* bitmap;
bitmap = Bitmap::FromResource(AfxGetApp()->m_hInstance, L"IDB_BITMAP1");
CachedBitmap cachedBitmap(bitmap, &graphics);
graphics.DrawCachedBitmap(&cachedBitmap, 10, 10);
I get nothing painted at all? I get no errors from the compiler at all either.
|
|
|
|
|
bitmap = Bitmap::FromResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCEW(IDB_BITMAP1));
|
|
|
|
|
Thanks Alex! That worked, although I still don't quite understand why it works.
|
|
|
|
|
Never mind, It's always the simple and obvious things that get me. It makes perfectly good sense to me now. The Documentation states:
Pointer to a null-terminated string that specifies the path name of the bitmap resource to be loaded. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. You can use the MAKEINTRESOURCE macro to create this value.
Thanks Alex.
|
|
|
|
|
Hello -- i am reading a list of values and need to convert certain strings to integers.
For example I have used the val() function in visual basic for this purpose. is there an equivalent in c++. (i know atoi works for type const char*, but what about the STL string)
thanks,
tim
p.s. in my code i have (where this is a relative date type in the form DHHMM) I need to modify the middle two values and then store the total as an int
61559
61600
61601
61602
61603
61604
61605
61606
---------------------------------------
Tim Booher
|
|
|
|
|
there is:
<br />
long atol(char* str)<br />
It will search through a character string until it reaches a character that is not a number and return the result as a long value.
|
|
|
|
|
atoi() or atol()
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
yeah -- but these aren't overloaded for the STL string -- i am getting conversion errors :<
tim
---------------------------------------
Tim Booher
|
|
|
|
|
use the c_str() function on your object and you will get a const char* to pass into these functions.
|
|
|
|
|
try:
int n = atoi(str.c_str());
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
sweet -- that works great i have:
string convertToMilitary(const string& strTime)
{
// input of form DHHMM i.e. 40112 = 4th day 1:12 pm
string strConverted = "";
int intHour = 0;
intHour = atoi(strTime.substr(1,2).c_str());
if (intHour < 9) intHour += 12;// what is the diff from +=
strConverted = strTime.replace(1,2,intHour);
// output of form DHHMM military (41312)
return strConverted;
}
now i just need to put them back together with all the zeros intact . . . I know i need to change intHour back to string with mask "00"
laters,
tim
---------------------------------------
Tim Booher
|
|
|
|
|
Hello everyone, I'm desperate.
What is going on with this. In debug mode it behaves correctly,
giving the correct output showing the insertions made into the
string:
C:\PleaseHelpMe>cd debug
C:\PleaseHelpMe\Debug>pleasehelpme
~@~bt~@~ <title>The Title of the Document ~@~et~@~ </title>
C:\PleaseHelpMe\Debug>pleasehelpme
~@~bt~@~ <title>The Title of the Document ~@~et~@~ </title>
But in release mode, nothing happens! No changes are made
to the string. Please help!
C:\PleaseHelpMe\Debug>cd ..
C:\PleaseHelpMe>cd release
C:\PleaseHelpMe\Release>pleasehelpme
<title>The Title of the Document </title>
What is going on? Please help I'm so confused!
Thank you
-Julie
// PleaseHelpMe.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <afx.h>
static TCHAR g_szBeginTitle[] = "~@~bt~@~";
static TCHAR g_szEndTitle[] = "~@~et~@~";
void InsertCode( TCHAR*& pszBuffer, TCHAR* pszKeyWord, bool& bLineChanged )
{
if ( pszBuffer )
{
*pszBuffer = ' ';
pszBuffer++;
while (*pszBuffer != '\0' && *pszKeyWord != '\0' )
{
*pszBuffer = *pszKeyWord;
pszBuffer++;
pszKeyWord++;
}
if ( pszBuffer )
{
*pszBuffer = ' ';
pszBuffer++;
}
bLineChanged = true;
}
}
void MarkHTMLSignificance( CString& strLine )
{
CString strNewLine;
int nLen = strLine.GetLength() + 2;
TCHAR* pszSource = strLine.GetBuffer( nLen );
TCHAR* pszResult = strNewLine.GetBuffer( nLen * 8 );
bool bLineChanged = false;
while (*pszSource != '\0')
{
if ( *pszSource == '<' )
{
LPTSTR pszTest = pszSource + 1;
switch ( *pszTest )
{
case 't': // possibly title
case 'T':
if ( _tcsnicmp( pszTest, _T("title"), 5 ) == 0 )
InsertCode( pszResult, g_szBeginTitle, bLineChanged );
break;
case '/':
pszTest++;
switch( *pszTest )
{
case 't':
case 'T':
if ( _tcsnicmp( pszTest, _T("title"), 5 ) == 0 )
InsertCode( pszResult, g_szEndTitle, bLineChanged );
break;
} // end switch on slash
} // end switch on t, h, b, slash
} // end if < found
*pszResult = *pszSource;
pszSource++;
pszResult++;
} // end while *pszSource != '\0'
*pszResult = *pszSource; // null terminate!!!
strLine.ReleaseBuffer();
strNewLine.ReleaseBuffer();
if ( bLineChanged )
strLine = strNewLine;
}
int main(int argc, char* argv[])
{
CString strHTML = " <title>The Title of the Document</title> \n";
MarkHTMLSignificance( strHTML );
printf( strHTML );
return 0;
}
|
|
|
|