|
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.
|
|
|
|
|
I am looking for a script parser written in C/C++ (that will compile under VC6 at least) that meets these requirements:
1) Simple VB-like instruction set (FOR/NEXT loops, IF/THEN/ELSE blocks, DO/WHILE loops, basic variable assignments and expression parsing). The lines of the source file are supplied from a text file (no editor front-end required).
2) Supports integer, floating, and string type variables.
3) Will compile into byte-code for faster, repeated runs.
4) The parser and byte-code interpretter are in C/C++ (MFC okay) and are open-source and/or GPL'd. No special binaries or libraries needed.
5) Nice-to-have-but-not-required: function support, GOSUB/GOTO, advanced math functions (sine/cosine), custom functions (PRINT)
I looked at MyBasic on this site as a basis but don't think I can use it because it lacks requirement #3. I also followed some of the links on the MyBasic message boards but couldn't find anything that would help. This script parser/interpretter is going to be a small part of a larger project and I was hoping not to re-invent this wheel. I am looking for something that is lean, easy to drop-in (or port), and quick enough to be used in a real-time application (as in a quick interpretter).
Any of you gurus have any suggestions? Or pointers where I can look?
Thanks in advance,
Paul
|
|
|
|
|
Take a look at GoldParser, its not written in C/C++ but you should be able to use it from VC6.
|
|
|
|
|
|
Your list is terrific, but in most situations scripting languages don't cover 3) as well as you might like. The most common approach is to code as much as you can in the scripting language, and only then if profiling shows that performance is insufficient, add a hook to optimised code written in C/C++ or dare I even say it, FORTRAN if required. Both Python and Lua meet all these requirements and both can be compiled to byte code.
You're also missing a few things fromt he list.
6) It needs to be easy to use (client usability)
7) It needs to be easy to integrate (programming perspective)
8) It needs to be easy to extend
The easiest way to achieve 6) is to use a language which most people already know or can learn very quickly. Custom languages or very small parsers / languages might have some quirks that take a while to work out
7) and 8) go hand-in-hand, and I would recommend picking a language on how easy it is to use, integrate and extend from the programmers perspective as well as the clients. Writing and maintaining language bindings is not the type of code that you'll want to write every day.
There are two major classes of bindings to languages at the moment - as a precompilation step (SWIG) or as part of the compilation (boost::python and luabind). My personal preference if for the later, because it guarantees that your bindings are always upto date.
http://www.lua.org/[^]
http://luabind.sourceforge.net/[^]
http://www.python.org/[^]
http://www.boost.org/libs/python/doc/index.html[^]
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Great suggestions! I looked into LUA and I think it will do all that I want - and more. It looks pretty well written and organized and it is always a bonus when I can learn from others.
|
|
|
|
|
Hi,
sounds easy, but it's very complicated...
I want to have a custom drawn TreeView with multiline items. The drawing of the tree works perfect but when the EditBox to edit the items text (TVN_BEGINLABELEDIT you know) is created it is - of course - singlelined.
Now I wanted to make it multiline and therefore I tried to use ModifyStyle but it didn't succeed.
The next approach was to create a CBT-Hook to hook the creation of the Edit and "smuggle" the ES_MULTILINE-Style into the windowstyle but strangely this also didn't succeed. Do you have any suggestions? the CBT-Hook is definitely called (I verified this with TRACE and Spy++).
Here's the HookProc-Code (hTree is the HWND of the tree):
LRESULT CALLBACK HookCreateWindow (int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == HCBT_CREATEWND) {
CBT_CREATEWND* pCWnd = (CBT_CREATEWND*) lParam;
if (pCWnd->lpcs->hwndParent == hTree) {
pCWnd->lpcs->style |= ES_MULTILINE;
TRACE("\nEdit_created. HWND: 0x%x", (HWND) wParam);
}
}
return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}
Thanks for your answers!
|
|
|
|
|
How are you planning on ending that editbox? Those labeledits are either aborted with esc or accepted by pressing enter. A multiline labeledit would instead create an extra line when the user hits enter. I suspect this is the reason the control is refusing to become multiline. A solution would be to overload the F2-key and pop up your own dialog with a multiline edit box, a OK button and a Cancel button.
|
|
|
|
|