|
Any chance any one knows how to make a check box look bigger?
I want to make it just a little bigger so the person doesn't
have to squint to see it. Any ideas? Any demo projects?
I searched everywhere but couldn't find anything.
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
You could subclass it and override DrawItem() . Or you could specify the "flat" style (in the resource editor) to make it (somewhat) easier to see.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello,
I have a CDialog with several buttons. On a button click, children class are called to execute something. My problem is that, sometime, the execution takes awhile, and I can't press the cancel button to stop the execution.
My code looks like that :
CParentClass{
CChildClass* m_ChildClass;
OnButtonClick(){
m_ChildClass->Execute();
}
}
CChildClass{
boolean m_cancel=false;
Execute(){
while(!m_cancel){
//do something
}
}
Thus, I would only want my Parent class to catch the cancel button clik and set the boolean m_cancel to false, while my child class is working.
And I would like this to be done at the parent class level, ie without affecting the code of the child class.
I have read things about threads, and it seems that I could use them to do what I want, but I have a hard time understanding the examples that I have found, ie where in the existing classes the threads need to be put. I have also seen things catching messages (peek message?) but it seems to me that this has to be done at the children class level, in the while loop...
Could anyone redirect me to very simple examples using threads, or help me ?
Thank you
|
|
|
|
|
sandrineV wrote:
I have read things about threads, and it seems that I could use them to do what I want
Yes, you are on the right track.
sandrineV wrote:
but I have a hard time understanding the examples that I have found
Most people are the same. It may take a while, it's not a simple subject, even experienced thread developers can be confused by a particular threading issue.
Here is an article on CodeProject: http://www.codeproject.com/threads/threads_and_mfc.asp[^]
There are many others on MSDN as well.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Thanks for your help, I have done the example suggested above, but still a lot of questions arise :
In the initInstance() method of the CMyThreadClass, this is done :
m_pMainWnd=new CMyDialogClass;
m_pMainWnd->SetForegroundWindow();
m_pMainWnd->ShowWindow(SW_SHOW);
Which means that when it is launched, the thread creates a new instance of a Dialog and displays it.
What if I just want to create a user interface thread on a button that is already defined in the main dialog of my class ?
Basically I would just like a "stop" button to be aware of clicks by the user, even though a child class is looping.
I think that one solution would be to create a thread for each child class, but I don't find this very pretty because no child class must run a the same time (except for the class implementing the "stop" command)
Another solution would be to create the "stop" command class as a worker thread, but then I suppose that a click on the button that launches the "stop" won't be accessible either.
Finally, I thought of creating a user interface threat which would handle the stop button, but if I create my Stop Button in the InitInstance() method of my CThreadClass, the button won't appear in the Dialog Ressource, and how can I display it ?
Could anyone tell me if these solutions seem relevant or not, and if one is better than the other ? Any advice would help, I'm a bit lost here.
Sorry again if these questions are irrelevant, but threads are really difficult
|
|
|
|
|
Hello,
How can I maximaze the window in run time in a MFC App
I need to do this without using the resasing button?
Please help me...
|
|
|
|
|
Check CWnd::ShowWindow
and SW_SHOWMAXIMIZED
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Ok,
But how do i set up this.
CDialogTest test;
test.ShowWindow(SW_MINIMIZE); This or how?
|
|
|
|
|
Larsson wrote:
Ok,
But how do i set up this.
CDialogTest test;
test.ShowWindow(SW_MINIMIZE); This or how?
NO.
Try to call it in your InitDialog method for example if you want the dialog to be launched minimized (or whatever)
or in an other place when needed
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Many programs, including VC++, allow the user to change the keyboard shortcuts. What I am searching for is an example of, or suggestions on, how to do this.
Heck! I would be happy for a Google search string; I've only narrowed it down to ~2700 hits so far.
Current search string:
"microsoft keyboard shortcut character mapping -accent -layout"
Thanks!
INTP
|
|
|
|
|
Read the article : "Beginner's Tutorial - Using global hotkeys "
at http://www.codeproject.com/system/nishhotkeys01.asp. I think it may help you
DavidR
|
|
|
|
|
:-DThanks!
This lead me to 'hot key control' and 'hot keys [Win32]', which may be what I was looking for.
INTP
|
|
|
|
|
I have written code which is designed to allow the printer to be changed in the background by reading a string from an ini file. My problem is that when I call the function
AfxGetApp()->SelectPrinter(hDevNames, hDevMode, TRUE), I find not all of my printers defaults have been read. If, however, I force a print dialog after the selection and just hit OK, then everything is fine. Any ideas on what I may be doing wrong would be appreciated. Thanks.
|
|
|
|
|
hai,
I want to attach a bitmap to my button using subclass.I'm using win32 vc++.
I have subclassed my button(IDC_BUTTON1). ie. i have done
lpfnOldWndProc = (WNDPROC)SetWindowLong( GetDlgItem(hDialog,IDC_BUTTON1),GWL_WNDPROC,(DWORD)SubClassFunc);
......
LONG FAR PASCAL SubClassFunc(HWND hWnd,
UINT uMsg,
WPARAM wParam,
LONG lParam)
{
}
but inside this SubClassFunc what should I do to attach the bitmap(IDB_BITMAP1)?
Can anyone help?
|
|
|
|
|
Subclassing is quite powerful, actually. Not only can you get a pre-sniff on what is going to happen, you can get a post-sniff as well.
The trick with post-sniffing is that you call the original window procedure first and save it's return value into a local variable. When this is done, check the uMsg parameter. If it is 'WM_PAINT', then enter a handler. In this handler, get the button's DC (You have the HWND, so just use GetDC ).
Then create a compatible DC with this one. Load the bitmap from file/resource. Select the bitmap into the memory DC. Blit from the memory DC into the button's DC so, that the starting point of the blit operation is NOT in point 0,0, but somewhere more to the middle. How middle it is is determined by the size of the bitmap and where you want it on the button. Use GetWindowRect to get the bouding rectangle of the button's DC. Then do math
But, all in all, the idea is to first allow the original window procedure to run, then do post-processing by applying the bitmap. Allowing the original procedure to run first ensures that the borders and the button state (normal/sunken) are drawn correctly.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
There's some problems in Hooking api.I inject my dll into the hooked process.The hooked api is gethostbyname.
I want to use MY_gethostbyname to replace the gethostbyname.While the My_gethostbyname was running,the wrong message appeared."Access violation at address 0102104D.Write of address 00000000." MY_gethostbyname's return value must wrong!I don't know how to write the funtion MY_gethostbyname.Who can help me? Thanks.
// hook.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <winsock2.h>
#include <windows.h>
#include <imagehlp.h>
#pragma comment(lib, "ImageHlp")
#pragma comment(lib,"Ws2_32")
extern "C" __declspec(dllexport) struct hostent* FAR MY_gethostbyname(const char* name
);
static void WINAPI ReplaceIATEntryInOneMod(PCSTR pszCalleeModName,
PROC pfnOrig, PROC pfnHook, HMODULE hmodCaller);
void process();
hostent *phostent=new hostent;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
process();
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
struct hostent* FAR MY_gethostbyname(const char* name)
{
//hostent *phostent=malloc(sizeof(hostent));
//MessageBox(NULL,"I'm in MY_gethostbyname",NULL,NULL);
unsigned int *ip[2]={0};
*ip[0]=3232235521;
*ip[1]=NULL;
phostent->h_addr_list =(char**)ip;
phostent->h_length =4;
return phostent;
}
static void WINAPI ReplaceIATEntryInOneMod(PCSTR pszCalleeModName,
PROC pfnCurrent, PROC pfnNew, HMODULE hmodCaller) {
// Get the address of the module's import section
ULONG ulSize;
PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)
ImageDirectoryEntryToData(hmodCaller, TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT, &ulSize);
if (pImportDesc == NULL)
return; // This module has no import section
// Find the import descriptor containing references to callee's functions
for (; pImportDesc->Name; pImportDesc++) {
PSTR pszModName = (PSTR) ((PBYTE) hmodCaller + pImportDesc->Name);
if (lstrcmpiA(pszModName, pszCalleeModName) == 0)
break; // Found
}
if (pImportDesc->Name == 0)
return; // This module doesn't import any functions from this callee
// Get caller's import address table (IAT) for the callee's functions
PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA)
((PBYTE) hmodCaller + pImportDesc->FirstThunk);
// Replace current function address with new function address
for (; pThunk->u1.Function; pThunk++) {
// Get the address of the function address
PROC* ppfn = (PROC*) &pThunk->u1.Function;
// Is this the function we're looking for?
BOOL fFound = (*ppfn == pfnCurrent);
// if (!fFound && (*ppfn > sm_pvMaxAppAddr)) {
// If this is not the function and the address is in a shared DLL,
// then maybe we're running under a debugger on Windows 98. In this
// case, this address points to an instruction that may have the
// correct address.
// PBYTE pbInFunc = (PBYTE) *ppfn;
// if (pbInFunc[0] == cPushOpCode) {
// // We see the PUSH instruction, the real function address follows
// ppfn = (PROC*) &pbInFunc[1];
// Is this the function we're looking for?
// fFound = (*ppfn == pfnCurrent);
// }
// }
if (fFound) {
// The addresses match, change the import section address
MessageBox(NULL,"Changing!",NULL,NULL);
WriteProcessMemory(GetCurrentProcess(), ppfn, &pfnNew,
sizeof(pfnNew), NULL);
return; // We did it, get out
}
}
// If we get to here, the function is not in the caller's import section
}
void process()
{
PROC oldpfn=GetProcAddress(GetModuleHandle("wsock32.dll"),"gethostbyname");
PROC newpfn=GetProcAddress(GetModuleHandle("hook.dll"),"MY_gethostbyname");
HMODULE exehandle=GetModuleHandle("DD.exe");
ReplaceIATEntryInOneMod("wsock32.dll",oldpfn,newpfn,exehandle);
}
|
|
|
|
|
Following on from my last post about how hyper-threading made my application crash in debug, but not release, I have come to the conclusion that it is MSDev which is at fault. I thought I would let you guys know in case you have the same problem and are flummoxed (like I was).
It turned out that in the debug version of my app, it sometimes caused a GPF if an ASSERT dialog box appeared. This was due to (I assume) one hyper-thread handling the ASSERT, and another handling the TRACE message I was also writing just before the ASSERT. I don't know why but this causes a GPF in my program.
So in future I must debug my program with the affinity of MSDev (and also therefore my program) set to "CPU 0" only. No crash - a bit slower, but no crash
Hope this makes sense and that someone at least reads it
Cheerz
Tha d3m0n
|
|
|
|
|
Hi, I´ve a problem installing fonts with VC++ in my computer.
The problem is once installed any font Type1 or TrueType, think that I have to activate font. Somebody know how to activate some font with VC++?
|
|
|
|
|
Hi, I´ve a problem installing fonts in my computer.
The problem is once installed any font Type1, think that I have to activate font. Somebody know the solution?
|
|
|
|
|
Once the font file is copied to the Fonts folder (defined at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Fonts), a value must also be added to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts registry key. This is all handled for you by the Fonts applet in Control Panel.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi one more time,
thank you for answering. I think that my problem is about Type1 fonts. When I copy the file .pfm and .pfb in C:\..\Fonts and use Adobe Type Manager to see it, I don´t see it right, but if I deactivate the font and turn it to activating with Adobe in option Groups then I can see it. I don´t know why?
Note: I´m sorry, but my English is not very good.
Thanks.
|
|
|
|
|
I added a web service to my VC++ application. To access it from within my project I do the following code:
WeatherService::CWeatherService *ws = new WeatherService::CWeatherService();
HRESULT hr = ws->GetWeather("KNEL");
if(hr == E_FAIL)
AfxMessageBox("Unable to retrieve current weather, Invalid Station Code", MB_OKCANCEL);
It's returning an E_FAIL by the SendRequest function.
Any ideas as to what I am doing wrong? It works fine when I call it from a managed C++ application.
Thanks
|
|
|
|
|
Humm..
I tried the same by using XMethods' WeatherService (gets the weather by zipcode, found "http://www.xmethods.net/sd/2001/TemperatureService.wsdl") and it works properly. As I have no idea what web service you are consuming (no link ?), then it is just about impossible to tell if your parameters are correct.
I, however, suggest checking the parameters. It looks like you are getting the weather for a station named "KNEL", but you are not saving the result value anywhere ? Check the function parameters. I believe that the parameter should be two-fold: upon input, it specifies the station name, and upon output, it gives you the weather.
I believe that it (GetWeather) requires a BSTR value as the first parameter. If you get into a dead-end when using a BSTR, paste a link to the web service into this forum, and I'll do a quick-check on how to call it properly.. Moreover, a little more detailed code paste from the function that is calling the web service would be useful. Are you initializing COM, for example ?
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
The code for GetWeather is as follows:
public void GetWeather(string stationcode)
{
Weather weather = new Weather();
GetWeather getweather = new GetWeather();
weather = getweather.GetWeatherObject(stationcode);
}
Yes it does require a BSTR as the parameter & it does not return any value, basically all the function does is update a database with the latest weather.
It seems to be failing in the atlSoap.h file in the SendRequest function when it tries to navigate to the url, it fails in sending the message to the server os the wuestion is WHY?
|
|
|
|
|
Could you please post a link to the actual web service, or is it for private use only ?
It is nearly impossible to say anything about the actual problem before debugging it personally. It looks like that the problem in the actual service, that it is unable to handle the request. But why, then again, impossible to say. Perhaps the implementation of the web service isn't programmed properly to support VC++ callers. The 'string' variable looks like .Net Framework variable, and as such, it is not directly compatible with the BSTR variables of VC++ COM architecture.
Unfortunately, I cannot help you further until I can give a few shots at using the web service myself.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|