|
Hello!
i'm making a mini-game by MFC
i want to make a class to ctrl some bitmaps,
i've written some menber founctions like this:
.................
in the constructor:
{
bitmap.loadbitmap...
xxx=0...//a bool to make sure CreateCompatibleDC(pDC) will only run once time.
}
setDC(CDC pdc);
{
if(xxx==0)
{
mDC.CreateCompatibleDC(pdc);// mDC used to store the picture
xxx=1
}
mDC.SelectObject(&bitmap[i]);
PDC=pdc;// PDC to store the target CDC
}
draw()//draw the picture
{
PDC->BitBlt(0,0,600,450,&mDC,0,0,SRCCOPY);
}
...........
but there's a problem:
when i use this class as a menber of CView; everything's OK ;
but when i use this class as menber of class X,and make X a menber of CView;
while using the founction setDC ;the mistake appears! a messagebox of"A\Retry\Ignore" comes out!!!
why things can be like this??
how should i write this class?
i just call setDC in founction"OnDraw".
modified on Sunday, July 12, 2009 4:12 AM
|
|
|
|
|
Please post relevant code where you're calling setDC.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
i just call setDC in founction"OnDraw".
|
|
|
|
|
If your class is a member of class X and then X is in-turn a member of the view class, how are you directly calling the setDC function of the class from OnDraw of the view class?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
all public menbers
just use it like: X.(this class).setDC;
|
|
|
|
|
I want write a program that will scan a drive after the user entered the letter of the drive for a file called autorun.inf and delete it.
it should also scan for sub-folders that have exe extension with the same name as it's parent folders and delete it.
I am a beginner in c++ and i appreciate any help you guys can offer
My OS is windows xp
i am using visual c++ 2008 express edition
|
|
|
|
|
You can use of FindFirstFile/FindNextFile on a loop it can searchs subfolders.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
To delete files recursively in sub folders, you can use the SHFileOperation[^] API.
To delete files having exe extension and name of it's parent folder you will need to use FindFirstFile[^] and FindNextFile[^] APIs as suggested by Hamid.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
OK i also want the user to enter the drive letter in the beginning of the program to scan it how to do this
|
|
|
|
|
You can get all the drives in your local system using the GetLogicalDrives[^] function.
Show all the available drives in a combo box and have the user select one from it.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Here is the class declaration.
There is no any interesting point.
class Sample
{
protected:
struct State
{
int q;
long a;
char z;
};
State m_state;
public:
Sample(){ Create();}
~Sample() { Destroy(); }
void Create()
{
m_state.q = 10;
}
void Destroy()
{
}
int getINT(){return m_state.q;}
};
But here is interesting. What is this???. Decleration. Definition. I Dont understand and i dont find any information about this part.
<code>
Sample& GetSample()
{
static Sample state;
return state;
}
</code>
The orginal parts of this code. in Directx SDK DXUT.cpp
Thank You!!!
|
|
|
|
|
- It declares and defines the function GetSample
- The function declares and defines a local static variable called state. As it's static, this variable retains it's value after the function exits even though it's local to the function
- The function returns a reference to state. It looks like it's trying to implement some sort of a singleton for the class Sample
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I plan on writing a command line program that will do some large, time consuming number crunching.
Now to keep it simple, lets say when I start my program all its going to do is count from 1 to infinity. Normally, when its running the loop it will "freeze" the program, per se, and not allow any additional user input until its done with the loop. However I would like the user to have the option to "pause" the loop without crashing to program. What is a simple way to interrupt a loop?
|
|
|
|
|
It sounds like you need to implement some sort of threading scenario, where your user interface operates on the main thread and the loop runs in a separate thread (which can be paused or restarted from the main thread.)
|
|
|
|
|
Have you tried _kbhit() in the loop?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi
I am trying to convert my networked application (C, using a custom text based protocol) to support UTF-8. I have search the Internet for a while now in order to find the best way to read UTF-8 from the socket, however, I have not been successful.
Can anyone point me in the right direction to get started? I have little experience with unicode programming in C, but know there exists a wchar_t type somewhere.
|
|
|
|
|
You don't want to use wchar_t for utf-8 encoded strings. Utf-8 was introduced to be able to use char .
I'd start from this link: UTF-8 and Unicode FAQ for Unix/Linux[^]. Never mind about the Unix part, it is useful even if you are working on Windows.
|
|
|
|
|
Sockets are used to transmit bytes of data. The socket API doesn't assume or impose any encoding, it's entirely up to the application level. If the application at the other end of the socket connection sends UTF-8 encoded data, then your recv() returns UTF-8 encoded data. There isn't any special "way to read UTF-8 from the socket".
|
|
|
|
|
Hello
I am working in a Win32 app using Visual Studio 2003.
And am using DialogBox function to create Modal dialogs. There's one dialog thats supposed to prompt the USER to whether Close the app or Not.
This is a high priority Dialog and i want it to displayed as the Top Most dialog irrespective of how many windows are open at a time.
Is there a way i can make this the TOP MOST window?
And also make all other opened windows invalid for the USER to make any Keyboard or Mouse clicks.
|
|
|
|
|
Superman did answer this question... you could have added to the conversation you've already started, instead of creating a new thread.
|
|
|
|
|
dipuks wrote: all other opened windows
In your app? That's what a modal dialog's meant to do. Make it a child of your app's topmost window.
dipuks wrote: Is there a way i can make this the TOP MOST window?
SetWindowPos[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Has anyone used CMFCRibbonStatusBarPane? Is there any way to force panes to update their text?
m_wndPane->SetText("my text"); will not update the UI..
You have to call:
m_wndPane->Redraw();
Wow!!!
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
modified on Saturday, July 11, 2009 8:04 PM
|
|
|
|
|
Hey Friends
Any idea how to get default command for any given file type
e.g for .cpl shell command is open with control panel
or
for .txt shell command is Open
Any sample / example can be of real help
Regards
|
|
|
|
|
You mean what ShellExecute[^] does, except without actually performing the command? I don't know of anything that does that, probably because the only thing you really want to do with a command like that is execute it.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
As Stuart said, you probably just want to execute the file using ShellExecute .
The command for the default operation is stored in the registry.
You should be able to read it for most of the file types.
There is no guarantee that all file types have this information.
Here goes -
Open the HKEY_CLASSES_ROOT registry key.
This hive will have a subkey with the extension of a file like .txt or .cpl
The default value of this key will contain another value like txtfile for .txt files and cplfile for .cpl files.
The HKEY_CLASSES_ROOT key also has subkeys with these values like txtfiles and cplfiles.
These subkeys in-turn will have a subkey called shell.
The subkeys of shell contain the names of the supported commands like Open, Runas etc.
Each of these keys contain a subkey called command whose default value is the actual command that is executed.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|