|
The first parameter to the CFontDialog c'tor is either a pointer to a LOGFONT structure or a reference to a CHOOSEFONT structure. If use the same structure every time (ie do not create a new one every time) then the CFontDialog will have the same settings as the last time.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I'm trying to obtain the recycle bin folder and have tried the following two ways. Both of them dont work, any idea what is wrong in each of them? I ran them on Windows XP.
<br />
void recycle_bin1()<br />
{<br />
char szPath[4096] = { '\0' };<br />
HRESULT hr = SHGetFolderPath(NULL, <br />
CSIDL_BITBUCKET,<br />
NULL,<br />
SHGFP_TYPE_CURRENT,<br />
szPath);<br />
<br />
const char *str = "SUCCEEDED";<br />
if (hr == S_FALSE) {<br />
str = "S_FALSE";<br />
} <br />
if (hr == E_FAIL) {<br />
str = "E_FAIL";<br />
}<br />
if (hr == E_INVALIDARG) {<br />
str = "E_INVALIDARG";<br />
}<br />
<br />
MessageBox(NULL, szPath, str, NULL);<br />
<br />
}<br />
void recycle_bin2()<br />
{<br />
char szPath[4096] = { '\0' };<br />
<br />
BOOL bRet = SHGetSpecialFolderPath(NULL, <br />
szPath,<br />
CSIDL_BITBUCKET, <br />
FALSE);<br />
<br />
const char *str = "SUCCEEDED";<br />
<br />
if (bRet == FALSE) {<br />
str = "FAILED";<br />
}<br />
<br />
MessageBox(NULL, szPath, str, NULL);<br />
<br />
}<br />
<br />
thanks!
|
|
|
|
|
|
|
The first one returns E_INVALIDARG and the second one returns FALSE.
MSDN doesnt say these APIs set the last error code, so I havent printed them.
I'm away from the computer that has this code, I will get back with the error codes in a couple of hours.
thanks!
|
|
|
|
|
Most APIs that return a BOOL will set the last error - otherwise there's no indication of what the error was.
SHGetFolderPath() is returning E_INVALIDARG because CSIDL_BITBUCKET isn't a constant that it supports (the docs list which ones it accepts, it's a subset of the full list).
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
OK, that means I cannot use both of SHGetFolderPath and SHGetSpecialFolderPath .
Btw, both of these APIs returned last error 6 (invalid handle), which in some sense is meaningless.
Looking at the codeproject article you gave, they use SHGetSpecialFolderLocation which supports CSIDL_BITBUCKET , but it returns LPITEMIDLIST and I am not sure how to obtain the folder name from that.
In any case, I was looking at the documentation of CSIDL_BITBUCKET again, and it gives me the virtual folder containing the items in the recycle bin. I'm not sure if COM is the only way to access the items in this virtual folder, as shown in the article, or if there is a simpler way too.
So, what I really want is, the name of the recycle bin folder on each of the drives on the system, like C:\RECYCLER. Since it is C:\RECYCLED on a FAT drive, I wanted to use a windows API to obtain the correct name. So, I guess CSIDL_BITBUCKET wont give me that - is this right?
So, may be I should just enumerate the drives, get the file system type, and use RECYCLED or RECYCLER appropriately. Here is a link that talks about these folder names - http://blogs.msdn.com/oldnewthing/archive/2006/01/31/520225.aspx[^] - although it is not clear from this link what happens to a folder named RECYCLER on a FAT drive that is converted to NTFS.
thanks!
|
|
|
|
|
oh oh OH... that's the sound of me realizing something. I was focussing on the return values and not the folder you were looking at. The Recycle Bin isn't a file system directory, so SHGetSpecialFolderPath() will never work. I don't know of an API to get the name of the actual file system dir (recycled/recycler/whatever it is). If you are interested in the contents of the Bin, then use SHGetSpecialFolderLocation() to get the PIDL to the Bin, then use the shell folder interfaces to enumerate the contents.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi guys. how can I access and manipulate a slider found in my texture dialog box that i have created. I have the following procedure that handles textures in my program
BOOL CALLBACK IDD_TEXTUREProc( HWND hWnd,<br />
unsigned int uiMsg,<br />
WPARAM wParam,<br />
LPARAM lParam )<br />
{<br />
unsigned int uiSize;<br />
<br />
switch( uiMsg )<br />
{<br />
case WM_INITDIALOG:<br />
SetWindowPos( hWnd, <br />
NULL, <br />
350, 300, <br />
0, 0, <br />
SWP_NOSIZE );<br />
<br />
<br />
return TRUE;<br />
break;<br />
<br />
case WM_COMMAND:<br />
switch( LOWORD( wParam ) )<br />
{<br />
case ID_TEXTUREDD_GENERATE:<br />
uiSize= ( unsigned int )GetDlgItemInt( hWnd, IDC_ROUGHNESS, NULL, true );<br />
<br />
g_bruteForce.GenerateTextureMap( uiSize );<br />
<br />
EndDialog( hWnd, 0 );<br />
return TRUE;<br />
break;<br />
<br />
case ID_TEXTURE_CANCEL:<br />
EndDialog( hWnd, 0 );<br />
return TRUE;<br />
break;<br />
}<br />
break;<br />
}<br />
<br />
return FALSE;<br />
}
And in my main, im doing this:
int WINAPI WinMain( HINSTANCE hInstance, <br />
HINSTANCE hPrevInstance, <br />
LPSTR lpCmdLine, <br />
int nCmdShow ) <br />
{<br />
while( true )<br />
{<br />
if( !g_glApp.HandleMessages( ) )<br />
break;<br />
<br />
if( g_glApp.MenuDown( ID_EXIT ) )<br />
PostQuitMessage( 0 );<br />
<br />
else if( g_glApp.MenuDown( ID_SCREENSHOT ) )<br />
g_glApp.TakeScreenshot( "screenshot.bmp" );<br />
<br />
else if( g_glApp.MenuDown( ID_GENERATE_TEXTURE_MAP ) )<br />
g_glApp.CreateDialogBox( IDD_TEXTURESIZE, IDD_TEXTUREProc );<br />
<br />
}<br />
}
What code do i need to insert in main and where??
Please Help!!
P:S: Both BOOL CALLBACK IDD_TEXTUREProc and int WINAPI WINMAIN are found in main.cpp
Thanks in advance
|
|
|
|
|
I am doing MFC Dialog Based programming in vc++.
I have import an icon and i want to put this icon on a button.
How can i put that icon on a button.
Please give step by Step process to add it on button.
Thanks in Advance.
alok chauhan
|
|
|
|
|
check this[^] out
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
|
Hi All
I want to find all the sites visited by a user in Mozilla Firefox.
As I know that for Internet Explorere there are some interfaces like IEnumSTATURL, IUrlHistoryStg2 etc. for finding history and cahche files of internet explorer.
So is there any similar way to find out history, cache, cookies etc. in Mozilla Firefox. Please tell me.
if not then please guide me the way to achive this.( better if provide some code snippets)
Thanks.
|
|
|
|
|
Hi,
I am developing a program using C++ and WinAPI (no MFC). It contains resources like dialogs and menus. What is the best way to make those resources language independent? I'd like to provide language packs for English, German etc...
|
|
|
|
|
People generally use different resource DLLs for different languages
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
|
In some modern programs,xml and picture files are used.
But the simple way is using resource dll
Easycvs is an easy and quick tool for version control system.it's a cvs integrated into Visual studio.
For more information,please visit http://www.easyvcs.com/
|
|
|
|
|
What are picture files?
Are there any benefits in using XML?
|
|
|
|
|
Hi, I have some questions, concerning three different things:
1.: if there is a text file with some identical lines in it, how can I find out, if there are identical lines and how can I delete these identical lines except of the first one?
2.: how can I replace the "GOTO" by an other statement? I already tried it with a simple "return", but that doesn't work.
_eins:
if (m_dlgSheet.DoModal() == IDOK) {
condition 1= ...
condition 2 = ...
if(condition1 != true&& condition2 != true) {
goto _eins;
}
}
3: do somebody know, how to implement a "zoom window"-function? Having this function, the user should be albe to draw with a left-mouse-klick a rectangle; while LMouseButtonUp, the content of the chosen rectangle should be enlarged to the whole size of the window. Maybe somebody knows a link or even source-code for this problem?
Hanno
|
|
|
|
|
1) there are many ways to do this, personaly I would read the file into a buffer line by line. Look at the basic_string or CString in MFC, these classes make it easy to compare to lines "strings" of text.
2) GOTO is an ugly statement. try:
while (!statement1 && !statement2) {
....
}
but beware that you could quite likely end up in an endless loop, you should have some sort of check in there and to exit the while loop use the break command
while (...) {
if (endless_loop)
break; // or return; will exit the function
}
3) maybe somebody else could better help you here. But here[^] is a project that might start you on the right track. You should also look on MSDN for mouse input functions here[^]
|
|
|
|
|
The 1st one:
------------
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iterator>
using namespace std;
struct LineOfText
{
LineOfText() : m_LineNumber(1) {}
unsigned int m_LineNumber;
string m_Text;
};
ostream& operator<<(ostream &s, const LineOfText &line)
{
s << line.m_Text << " (line " << line.m_LineNumber << ")";
return s;
}
struct SortByText
{
bool operator()(const LineOfText &l, const LineOfText &r) const
{
return l.m_Text < r.m_Text;
}
};
struct IsTextEqual
{
bool operator()(const LineOfText &l, const LineOfText &r) const
{
return l.m_Text == r.m_Text;
}
};
struct SortByLine
{
bool operator()(const LineOfText &l, const LineOfText &r) const
{
return l.m_LineNumber < r.m_LineNumber;
}
};
typedef vector<LineOfText> Lines;
Lines g_Lines;
int main(int argc, char* argv[])
{
// Open the input file.
ifstream ifs("C:\\a.txt");
if (!ifs)
{
return 1;
}
// Read lines of input file into a vector.
LineOfText line;
while (getline(ifs, line.m_Text))
{
g_Lines.push_back(line);
++line.m_LineNumber;
}
// Elimiate duplicate text but keep what remains in line order.
stable_sort(g_Lines.begin(), g_Lines.end(), SortByText());
Lines::iterator new_end = unique(g_Lines.begin(), g_Lines.end(), IsTextEqual());
sort(g_Lines.begin(), new_end, SortByLine());
// Output the results.
copy(g_Lines.begin(), new_end, ostream_iterator<LineOfText>(cout, "\n"));
return 0;
}
Steve
|
|
|
|
|
hi
i have a simple question, I usually see such line of code in someones class(for example) :
void CSomeClasss::Get(CString str, TCHAR tchar )
{
...
}
I am interested in what is the use of writing /*= _T(' ')*/
-- modified at 2:43 Saturday 18th March, 2006
|
|
|
|
|
Nothing special...It is just to remind oneself what kind of input he is recieving at the time of calling. Statement written between /* and */ is not executed in c++. We use it to explain, what this piece of code is doing. So you can write any thing between it.
Good Luck.
We Believe in Excellence
www.aqueelmirza.cjb.net
-- modified at 2:53 Saturday 18th March, 2006
|
|
|
|
|
It's just tell compilers and readers that this parameter is not used in this function.You will appreciate it if you are using visual c++ and set the warning level to 4
Easycvs is an easy and quick tool for version control system.it's a cvs integrated into Visual studio.
For more information,please visit http://www.easyvcs.com/
|
|
|
|
|
"It's just tell compilers and readers that this parameter is not used in this function"
if so then why don't simply remove this parameter >
|
|
|
|
|