|
The easiest way is to #include <AtlConv.h> and use the A2W macro.
USES_CONVERSION;
res = NetShareEnum (A2W(lpszServer), 502, ...
Look up "ATL and MFC String Conversion Macros" in MSDN.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
In my app i have a bitmap button
i set the bitmap of the button like so
m_BrowseFile.SetBitmap( LoadBitmap( AfxGetInstanceHandle(), MAKEINTRESOURCE( IDB_OPEN ) ) );
now in the bitmap file the background is gray, and that gray area is showing up
how do i get rid of the gray background?
|
|
|
|
|
Use LoadImage() instead of LoadBitmap() , and specify the LR_LOADMAP3DCOLORS and LR_LOADTRANSPARENT flags.
m_BrowseFile.SetBitmap((HBITMAP)LoadImage(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_OPEN),
IMAGE_BITMAP,
0, 0,
LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT));
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
In my project, I need to automate the process of building a new network connection. You can manually set up a new connection as the following: "Control Panel" -> "Network Connections" -> "Create a new connection" -> Click "next" -> "setup an advanced connection" -> next -> ... We can assume that it is fixed process.
Is there any scripting tool or Windows API which I can use to automate the above process in my VC++ program? Anybody can give me a hint? Thanks a lot
-Jeff
|
|
|
|
|
Hi Jeff,
You can use the RAS API (Remote Access Service) to solve your problem. There's examples how to use it in MSDN.
Cohen
|
|
|
|
|
HI~
struct b
{
LPWSTR c;
}
struct a
{
b* d;
}
a* e;
e = new a[100];
a f;
f.d = new b[1000];
b g;
g.c = _T("HIHI");
f.d[0] = g;
e[0] = f;
if I delete pointer e by this statement:
delete [] e;
can it free all the memory including the dynamic array (pointer d) in structure a and the LPWSTR type string pointer in structure b?
or I need to free pointer d first or free pointer c first?
thanks
|
|
|
|
|
can it free all the memory including the dynamic array (pointer d) in structure a and the LPWSTR type string pointer in structure b?
or I need to free pointer d first or free pointer c first?
No, you shouldn't point the existing pointer with new a[100] assigned
to another pointer. Doing so will cause the memory leak of size struct a * 100 cause the system find no way to reclaim back the memory you allocated, the address that the pointer point to has changed.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
that is some weird code.
If you run it I think f.d = new b[1000]; will not be deleted
You dont always want to delete this pointer though because some times it is pointing to data on the stack, f.d[0] = g;
Basiacally what you have here is a big mess.
|
|
|
|
|
Is it possible to use animated cursors or small animated gifs as bitmap on a toolbar. My search on google and here did not turn up anything.
|
|
|
|
|
Everything is possible.
But, doing what you describe requires that you create a custom toolbar control that animates the buttons. Windows standard toolbar does not provide the functionality you require.
Easiest way to start is to search here on CP for animatable buttons. Then laden these buttons in a row over a Rebar control, and attach it to the top of the window. It works just like a toolbar, but is made and upkept by you.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
how to disable the task manager while my program runnig
|
|
|
|
|
There is no such way.
The Task Manager is a crucial Windows component that allows the user to shut down programs or processes that have stopped working or are behaving incorrectly. Disabling it would mean that the user loses the majority of control that he/she has over what programs are running on the system.
As such, disabling it is not an option. Whatever you are trying to implement, you should consider implementing it differently.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
This is what I use to disable the task manager
during games and such.
Regsitry
Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System
Key
DisableTaskMgr
Thank You
Bo Hunter
|
|
|
|
|
|
I handle a check menu item like this:
// the update command
void CAppDlg::OnUpdateMenuItem(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(BoolVar);
........
}
and
// the command
void CAppDlg::OnInterfaceMenuItem()
{
BoolVar = BoolVar == 0 ? 1 : 0;
}
The solution works with one exception: when the item is not checked the sign before the caption does not dissapear (but it works just fine). How do i get that "check" sign to dissapear ? If the check state is false, should not dissapear by default ?
|
|
|
|
|
Hi all,
I have an application (win .exe app) and I wish it could be running background. But it needs keyboard and mouse input which is fixed and could be prepared in advance. So I saved mouse/keyboard in a file, and I am trying to code a small program which could send mouse/keyboard to my background app.
I read several example in codeproject about hook mouse/keyboard message and tried to insert mouse/kb events using WH_JOURNALPLAYBACK hook. Unfortunately, the hWnd parameter is ignored so my mouse/kb messages are always sent to active window, not background app.
Now I am lost. Could anyone please give me a direction?
Thanks in advance,
Joe
|
|
|
|
|
Im having a smiliar question and was about to post it, but mine is almost the opposite.
I have a background app that has a recorded sequence of key presses and I want to send them to my foreground app.
I think possibly the answer to your question may be answer to my question.
Now, I have tried things like hooking the KB, and tried code segments like this one:
void SetRIGHT( BOOL bState )
{
BYTE keyState[256];
GetKeyboardState((LPBYTE)&keyState);
if( (bState && !(keyState[VK_RIGHT] & 1)) ||
(!bState && (keyState[VK_RIGHT] & 1)) )
{
// Simulate a key press
keybd_event( VK_RIGHT,
0x45,
KEYEVENTF_EXTENDEDKEY | 0,
0 );
// Simulate a key release
keybd_event( VK_RIGHT,
0x45,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
0 );
}
}
Then moving foreground to my app I want to recieve the input, alas, it dosent do what I want it to. It does however result in strange things happening like the right and left arrow keys get stuck so I have to hit them twice, im sure its a conflict in what im doing.
Anyhow, Thanks in advance,
Charles
|
|
|
|
|
I have successfully send kb/mouse message to a foreground applications. I would like to suggest you have a look at the following example at codeproject, it's quite good.
http://www.codeproject.com/tools/winmacro.asp by:S. Senthil Kumar
The example includes recording kb/mouse input and playback. I modified it and only use the playback part. That is only the WH_JOURNALPLAYBACK hook.
You might need to prepare lpara for the playback hook. I generated a file by using WH_JOURNALRECORD hook to keep my kb/mouse event.
Regards,
Joe
|
|
|
|
|
Thanks for the advice, i will look at that shortly.
I did find one in VB, but I cant use that, it dosent look like you can either, but maybe you can get an idea I didnt.
http://www.devx.com/vb2themax/Tip/19094
|
|
|
|
|
Following my first dumb question, I #include number[2].
Sorry about that! Being a newb is a bitch!!!
How do you NULL arrays?
Is it ok to:
int numbers[10] = { 1, 23, 50, 2, NULL};
Or do I have to:
int numbers[10] = {NULL}; and then assign values using a second statment!
Apriciate the help!
|
|
|
|
|
why do you wan't to NULL them? There's no need to
modified 12-Sep-18 21:01pm.
|
|
|
|
|
There is another thread that started just this morning, asking a very similar question about how to initialize arrays with zero values.
See "Arrays!" by CreepingFeature which was posted at 8:58 this morning. There are many replies that will answer your questions on array initialization.
Best Regards,
Shawn
|
|
|
|
|
That was my thread!
|
|
|
|
|
Ya don't say. Well I'm confused then. NULL stands for the number zero. If you really want to use NULL you have to write a for loop, I'm sorry to say. But that is rather pointless if it is zero anyway. Just follow the advice on the other thread.
Shawn
|
|
|
|
|
As arrays of data are placed sequentically in memory (at least on unmanaged/non .Net programs), then you can use ZeroMemory to set the entire array area to zero. Alternatively, you can use ZeroMemory in conjuction with array indexes to clear certain sections. A few examples:
int nArray[20];<DIV>
ZeroMemory( &nArray[0], sizeof(int) * 3 );<DIV>
ZeroMemory( &nArray[10], sizeof(int) * 5);<DIV>
ZeroMemory( &nArray[19], sizeof(int) ); Hope these will help you.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|