|
BrockVnm wrote:
Does anyone know what file (if there is any) I would have to edit to change settings like their outgoing mailserver?
Start with the HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\OMI Account Manager\Accounts registry key.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
I shouldn't have initiated another thread really, but I think that, although the previous question is similar to this new one, this one I have stumbled across with is a bit different.
The question is I have shown a vertical scrollbar in a custom control (by calling ShowScrollBar , but, although I keep it updated by notifying it of the mins and maxes and the current position, it is behaving as if it was still expecting to be initiated: the bar doesn't work; you can't drag the bar as it is always in the same position; . . .
Are there any steps I am missing out here?
Thank you very much for your time.
David
|
|
|
|
|
Please give us a code fragment, so we might see, what's your problem. In general, scrollbars do their work.
|
|
|
|
|
Hi
You may have to add ON_WM_VSCROLL() to your message map and implement the function, maybe something like this, which works for me. Think I stole some of it from mfc's own CScrollView, take a look here too. Don't know why this doesn't work automatically inside mfc. I feel like (by calling SetScrollPos()) I'm telling the scrollbar something it actually already knows. Well mfc is not alway intuitive, and always trying to figure out "why" will make you go nuts . Who knows why scrolling works like this, am I completely out of track here?
- Jesper
void EPropListCtrl::OnVScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar )
{
int nNewPos = -1;
int sp = GetScrollPos(SB_VERT);
if( nSBCode==SB_THUMBPOSITION || nSBCode==SB_THUMBTRACK )
{
nNewPos = nPos;
}
else if( nSBCode==SB_LINEUP )
{
sp -= 5;
nNewPos = sp;
}
else if( nSBCode==SB_LINEDOWN )
{
sp+=5;
nNewPos = sp;
}
else if( nSBCode==SB_PAGEUP )
{
sp-=20;
nNewPos = sp;
}
else if( nSBCode==SB_PAGEDOWN )
{
sp+=20;
nNewPos = sp;
}
if( nNewPos >= 0 )
{
SetScrollPos( SB_VERT , nNewPos );
Invalidate();
}
}
|
|
|
|
|
This is very distressing!
I have been taking a look at some sites and apparently there is much more to scrollbars than it actually seems to be at first.
Do you know if there is a (more) straight forward approach on how to [manually] program scrollbars?
David
BTW: Thanks a lot for the code -- it was very helpful.
|
|
|
|
|
I have around five years of mfc programming behind be, and one thing I've learned is that there is no such a thing as "forward approach". But as I mentioned before, looking at mfc's own scroll code may help you a great deal.
And btw, don't forget, you'll have to set the dc's viewportorg yourself before drawing in your OnPaint() function. This is what makes the control scroll its contents.
something like this (please forgive me if this doesn't compile, it's straight out of my mind..)
void SomeControl::OnPaint()<br />
{<br />
<br />
<br />
CPaintDC dc(this);<br />
int orgx = GetScrollPos(SB_HORZ);<br />
int orgy = GetScrollPos(SB_VERT);<br />
dc.SetViewPortOrg(-orgx,-orgy);<br />
<br />
<br />
dc.MoveTo(0,0);<br />
dc.LineTo(100,100);<br />
<br />
}
Good luck
- Jesper
|
|
|
|
|
Thanks a lot Jesper.
Like I said in my previous post, you have been very helpful.
I only hope I may be of assistance to you in the future.
Cheers,
David
|
|
|
|
|
This article in MSDN
and for example this code in MFC 6 (dllole.cpp) (same in dllnet.cpp) don't connect:
<br />
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID )<br />
{<br />
if (dwReason == DLL_PROCESS_ATTACH)<br />
{<br />
BOOL bRegister = !extensionDLL.bInitialized;<br />
AFX_MODULE_STATE* pModuleState = _AfxGetOleModuleState();<br />
pModuleState->m_hCurrentInstanceHandle = hInstance;<br />
pModuleState->m_hCurrentResourceHandle = hInstance;<br />
pModuleState->m_pClassInit = pModuleState->m_classList.GetHead();<br />
pModuleState->m_pFactoryInit = pModuleState->m_factoryList.GetHead();<br />
VERIFY(AfxInitExtensionModule(extensionDLL, hInstance));<br />
<br />
AfxCoreInitModule();<br />
<br />
AfxWinInit(hInstance, NULL, _T(""), 0);<br />
<br />
if (bRegister)<br />
COleObjectFactory::RegisterAll();<br />
<br />
VERIFY(AfxSetModuleState(AfxGetThreadState()->m_pPrevModuleState) ==<br />
_AfxGetOleModuleState());<br />
DEBUG_ONLY(AfxGetThreadState()->m_pPrevModuleState = NULL);<br />
<br />
CDynLinkLibrary* pDLL = new CDynLinkLibrary(extensionDLL, TRUE);<br />
ASSERT(pDLL != NULL);<br />
pDLL->m_factoryList.m_pHead = NULL;<br />
}<br />
else if (dwReason == DLL_PROCESS_DETACH)<br />
{<br />
AfxTermExtensionModule(extensionDLL);<br />
<br />
ASSERT(AfxGetThreadState()->m_pPrevModuleState == NULL);<br />
AfxGetThreadState()->m_pPrevModuleState =<br />
AfxSetModuleState(_AfxGetOleModuleState());<br />
<br />
AfxTermExtensionModule(extensionDLL, TRUE);<br />
}<br />
else if (dwReason == DLL_THREAD_DETACH)<br />
{<br />
AfxTermThread(hInstance);<br />
}<br />
<br />
return TRUE;
}<br />
<br />
<br />
void AFXAPI AfxOleInitModule()<br />
{<br />
ASSERT(AfxGetModuleState() != AfxGetAppModuleState());<br />
<br />
CDynLinkLibrary* pDLL = new CDynLinkLibrary(extensionDLL, TRUE);<br />
ASSERT(pDLL != NULL);<br />
pDLL->m_factoryList.m_pHead = NULL;<br />
}<br />
Because in the article it says that only if a DLL will be used from MFC exe it's OK to put:
<br />
CDynLinkLibrary* pDLL = new CDynLinkLibrary(extensionDLL, TRUE);<br />
in DLLMain but MFCs code has it anyway which translated into:
<br />
Detected memory leaks!<br />
Dumping objects -><br />
{68} client block at 0x033C4D88, subtype 0, 64 bytes long.<br />
a CDynLinkLibrary object at $033C4D88, 64 bytes long<br />
{64} client block at 0x033C4AA8, subtype 0, 64 bytes long.<br />
a CDynLinkLibrary object at $033C4AA8, 64 bytes long<br />
{57} client block at 0x033C2E18, subtype 0, 64 bytes long.<br />
a CDynLinkLibrary object at $033C2E18, 64 bytes long<br />
Object dump complete.<br />
In my situation.
I do call
<br />
AfxOleInitModule();<br />
AfxNetInitModule();<br />
in my regular DLL as ordered by the article. Now what?
|
|
|
|
|
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
|
|
|
|
|