Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all 3027 articles
Browse latest View live

setlocale() with LC_MESSAGES

$
0
0
I'm building the Windows version of a cross-platform app. It was originally written for gcc (i.e. mingw, on Windows) but in my case I'm building with MSVC. One of the source modules has this line:-

Code:

setlocale (LC_MESSAGES, NULL);
The above line crashes if I build with MSVC. I guess that's not surprising because MSVC doesn't have any support for LC_MESSAGES.

But... what is it that doesn't support LC_MESSAGES? Is it MSVC - or does Windows itself not support LC_MESSAGES? I'm only asking because the same code built with mingw doesn't crash. Is that a happy accident? Or does mingw somehow manage to support this on Windows when MSVC can't??

Code template writer

$
0
0
Hi guys, I'm learning C++, but I have no idea about how to write this program.

"Write a program to read in a filename via stdin and write a C++ source template to it. Ensure that the generated file compiles and runs. Such a template would have at least a #include directive and an empty main function, ready to be filled. Once you have written this program, you may use it to jumpstart your work on other programs. "

Please help. Thanks

New to C++

$
0
0
Hello all,

I have recently began learning C++. My programming experience is limited mainly to the old VB, VB6 and a bit of experience with VB.NET... I started programming in high school back in 1980 using a PDP11 time sharing system... Those were the days...

I am still very new to the *new* Visual Studio versions, C and C++. I have always wanted to learn C, I started doing that awhile ago but got sidetracked. So far the task seems daunting but I am moving along slow and steady...

I want to build an app where performance is key, using (I think) VCPP. From what I gather, CLR and the .NET framework is not the ideal choice if speed is key. So I am trying to figure out how to use just native C++, or whatever is the fastest possible route.

I am using Visual Studio 2010, I am very familiar with the Visual IDE from my VB6 days and thought that I could start my project by choosing a "windows forms project"... But as I begin and look at the control toolbox I see a tooltip telling me that these controls are .NET controls, which makes me wonder exactly what I'm getting into starting out like this.

Any suggestions are much appreciated.

T

C++ Disabling printscreen key

$
0
0
Hi,

Im new to c++ and I was wondering if someone can help me.

I would like to disable the printscreen key inside a game.

I run a small online game server and if a player uses printscreen key rapidly

he can blink something like using a cheat engine to run faster.

I would like to have a code to work in visual studio > compile > hook to my .exe

I dont know if it is the right way to stop printscreen key in game.

Thank you.

Hooking COM objects using DLL injection in a Process

$
0
0
Hi everyone,

In my research I want to hook (intercept) the method (virtual tables hook) "ExecQuery" of "IWbemServices" interface(COM objects)
and I use Application Verifier (note: important only for injection in this thread) to inject a dll in the beginning of a specific process.

We can assume that the above process is using com objects and will use "ExecQuery" method during its execution, ("CoCreateInstance" and "ConnectServer" too.).

I want the dll to hook "ExecQuery" after injection. (ofcourse I waited till ole32.dll and fastprox.dll were loaded).
From my knowledge I know I need to create a com instance, and use it to query "IWbemServices" interface.
After I get the interface I can hook the virtual table of it.

Code copy of the process to execute:

Code:

wchar_t comName[MAX_PATH]=L"test";
        DWORD dComputer = MAX_PATH;
        WCHAR temp[MAX_PATH];// = L"ProcessorNameString";
        //LPSTARTUPINFOW stinfo=NULL;

        char lzValue[255];
        HKEY hKey;
        LONG returnStatus;
        DWORD dwType = REG_SZ;
        DWORD dwSize = 255;
        unsigned int i = 1000;
        HRESULT hres;
        IEnumWbemClassObject* pEnumerator;
        IWbemServices *pSvc=NULL;
        IWbemLocator *pLoc = NULL;


        hres = CoInitializeEx(0, COINIT_MULTITHREADED);
        hres = CoInitializeSecurity(
                NULL,
                -1,                          // COM authentication
                NULL,                        // Authentication services
                NULL,                        // Reserved
                RPC_C_AUTHN_LEVEL_DEFAULT,  // Default authentication
                RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation 
                NULL,                        // Authentication info
                EOAC_NONE,                  // Additional capabilities
                NULL                        // Reserved
                );

        unsigned int te2 = GetLastError();
        printf("%d\n",te2);
        hres = CoCreateInstance(
                CLSID_WbemLocator,
                0,
                CLSCTX_INPROC_SERVER,
                IID_IWbemLocator, (LPVOID *)&pLoc);

        te2 = GetLastError();
        printf("%d\n", te2);
        hres = pLoc->ConnectServer(
                L"ROOT\\CIMV2", // Object path of WMI namespace
                NULL,                    // User name. NULL = current user
                NULL,                    // User password. NULL = current
                0,                      // Locale. NULL indicates current
                NULL,                    // Security flags.
                0,                      // Authority (for example, Kerberos)
                0,                      // Context object
                &pSvc                    // pointer to IWbemServices proxy
                );
        te2 = GetLastError();
        printf("%d\n", te2);
        hres = pSvc->ExecQuery(L"WQL", L"SELECT * from Win32_Processor", WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);



Code copy of DLL:
Code:

BOOL WINAPI DllMain(
        _In_ HINSTANCE hinstDLL,
        _In_ DWORD fdwReason,
        _In_ LPVOID lpvReserved
        )
{
        PRTL_VERIFIER_PROVIDER_DESCRIPTOR* pVPD = (PRTL_VERIFIER_PROVIDER_DESCRIPTOR *)lpvReserved;

        UNREFERENCED_PARAMETER(hinstDLL);


        switch (fdwReason) {

        case DLL_PROCESS_VERIFIER:
                ucmRegisterProvider(); // new - getting callback of every loaded dll       
                *pVPD = &avrfDescriptor;
                break;
        }
        if (t1 == 1) //wait till "fastprox.dll" is loaded...
        {
                InstallComInterfaceHooks(NULL);
        }
        return TRUE;
}



HRESULT InstallComInterfaceHooks(IUnknown* originalInterface)
{
        HRESULT hres2;
       

        IWbemLocator *pLoc2 = NULL;

        hres2 = CoCreateInstance(
                CLSID_WbemLocator,
                0,
                CLSCTX_INPROC_SERVER,
                IID_IWbemLocator, (LPVOID *)&pLoc2);

        IWbemServices *pSvc2 = NULL;

        hres2 = pLoc2->ConnectServer(
                BSTR(L"ROOT\\CIMV2"), // Object path of WMI namespace
                NULL,                    // User name. NULL = current user
                NULL,                    // User password. NULL = current
                0,                      // Locale. NULL indicates current
                NULL,                    // Security flags.
                0,                      // Authority (for example, Kerberos)
                0,                      // Context object
                &pSvc2                    // pointer to IWbemServices proxy
                );


        // Only single instance of a target object is supported in the sample
        if (g_Context.get())
                return E_FAIL;

        // getting the interface of the object
       
        //IUnknown *so;
        IWbemServices *so = NULL;
        //CoCreateInstance(CLSID_IWBEM)
        //ATL::CComPtr<IWbemServices> so;
        HRESULT hr = pSvc2->QueryInterface(IID_IWbemServices, (void**)&so);
        if (FAILED(hr))
                return hr; // we need this interface to be present

        // remove protection from the vtable
        DWORD dwOld = 0;
        if (!::VirtualProtect(*(PVOID**)(originalInterface), sizeof(LONG_PTR), PAGE_EXECUTE_READWRITE, &dwOld))
                return E_FAIL;

        // hook interface methods
        g_Context.reset(new Context);
        HookMethod(originalInterface, (PVOID)Hook::ExecQuery, &g_Context->m_OriginalExecQuery, 20);

        return S_OK;
}


The COM functions used in MAIN(above process) are working.


I get an E_FAIL from
"hres2 = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *)&pLoc2);"
code in dll function.

and IWbemLocator and IWbemServices stay NULL.

any suggestions?

A working code sample will be good also.

How can I convert the strings to integers?

$
0
0
Hello, everybody can y'all be so kind to help me with my program? I am trying to convert strings to integers. This is my task:
Open a file "numbers.txt"
read integer numbers as strings from the file (one number per line)
convert each string to a numeric representation (without using stoi() or similar functions from the string library)
store converted numbers in an array
close "numbers.txt"

So far I have read integer numbers as strings but cannot convert the string array to integers without using the string library. Can someone help? My code won't compile but I am trying to do this: 154: Sum = 4*1 + 5*10 + 1*100 = 154 so it can convert to an integer.
This is what I have so far:
Code:

#include <fstream>
#include <string>
#include <sstream>
#include <iostream>
using namespace std;

int StringToInteger( string arraySize);

int main()
{
  ifstream infile;
  infile.open("numbers.txt");
  const int size = 1000;
  string myArray[size];
  int i = 0;
  while (infile >> myArray[i])
  {

      cout << "The string is \"" << myArray[i] << "\"" << endl;

      myArray[i].size();
      cout << i << endl;
     
      StringToInteger(i);
      ++i;

     
  }
}

int StringToInteger( string arraySize)
{
  int values = 0;
  for (int index = 0; index < arraySize.size; index++) {
      values *= 10;
      values += (arraySize[index] - '0');
  }
  return values;
}

[RESOLVED] Need help with piece of code

$
0
0
Code:

#include "stdafx.h"
#include <iostream>
#include <string>       
#include <Windows.h>

int main()
{
        int mxhp, chp, emxhp, echp;
        int atk, def, dam;
        int eatk, edef, edam;
        int mxmp, cmp, matk, mdef, mdam, ematk, emdef, emdam;
        int choice;
        int level, mxlevel;

        level = 1;
        mxlevel = 1;
               
        while (level == 1)
        {
                mxhp = 100;
                chp = 100;
                atk = 20;                //You and your Enemies stats
                def = 15;                //E at the beginning indicates it's the enemies stats
                emxhp = 80;
                eatk = 30;
                edef = 10;
                echp = 80;
                dam = atk - edef;
                edam = eatk - def;

              std::cout << "#######################" << std::endl;
                std::cout << "Your HP:" << chp << std::endl;          //Move selection menu
                std::cout << "#######################" << std::endl;
                std::cout << "Enemy HP:" << echp << std::endl;
                std::cout << "#######################" << std::endl;
                std::cout << "What will you do?" << std::endl;
                std::cout << "1. -> Attack" << std::endl;
                std::cout << "2. -> Heal" << std::endl;

                std::cin >> choice;

                if (choice == 1)
                {
                        std::cout << "You did" << dam << "to the opponent!" << std::endl;  //Showing your damage
                        system("pause");

                        echp = emxhp -= dam;

                }
                if (choice == 2)
                {
                        std::cout << "You healed yourself!" << std::endl;

                        if (chp < 100)
                        {
                                chp = mxhp += 25;    //How much you heal yourself

                        }

                }

                else
                {
                        std::cout << "Please choose an option" << std::endl;
                }

                std::cout << "The enemy attacked!" << std::endl;                  //Showing Enemy damage
                std::cout << "The enemy did" << edam << "to you!" << std::endl;
                system("pause");
                system("cls");

                chp = mxhp -= edam;

                if (echp <= 0)
                {
                        std::cout << "You won!" << std::endl;  //End screen
                        std::cout << "Skills learned:" << std::endl;
                        std::cout << "Fire" << std::endl;
                        std::cout << "Items Obtained:" << std::endl;
                        std::cout << "None" << std::endl;
                        std::cout << "Stats Increased:" << std::endl;
                        std::cout << "Attack" << std::endl;
                        level = mxlevel += 1;
                        break;
                }

                if (chp <= 0)
                {
                        std::cout << "You lost..." << std::endl; //End screen
                        break;
                }

        }

                while (level == 2)
                {
                        mxhp = 100;
                        chp = 100;
                        mxmp = 20;                  //You and your Enemies stats
                        cmp = 20;
                        atk = 25;
                        matk = 15;
                        def = 15;
                        mdef = 10;
                        emxhp = 100;
                        eatk = 30;
                        ematk = 0;
                        edef = 20;
                        emdef = 0;
                        echp = 100;
                        dam = atk - edef;
                        mdam = matk - emdef;
                        edam = eatk - def;
                        emdam = ematk - mdef;

                        std::cout << "#######################" << std::endl;
                        std::cout << "Your HP:" << chp << std::endl;
                        std::cout << "Your Mp:" << cmp << std::endl;
                        std::cout << "#######################" << std::endl;
                        std::cout << "Enemy HP:" << echp << std::endl;
                        std::cout << "#######################" << std::endl;
                        std::cout << "What will you do?" << std::endl;
                        std::cout << "1. -> Attack" << std::endl;
                        std::cout << "2. -> Heal" << std::endl;
                        std::cout << "3. -> Fire" << std::endl;

                        std::cin >> choice;

                        if (choice == 1)
                        {
                                std::cout << "You did" << dam << "to the opponent!" << std::endl;  //Showing your damage
                                system("pause");

                                echp = emxhp -= dam;
                        }
                        if (choice == 2)
                        {
                                std::cout << "You healed yourself!" << std::endl;

                                if (chp < 100)
                                {
                                        chp = mxhp += 25;    //How much you heal yourself

                                }
                        }
                        if (choice == 3)
                        {

                                if (cmp >= 5)
                                {
                                        std::cout << "You cast fire!" << std::endl;    //Showing your damage
                                        cmp = mxmp -= 5;
                                        echp = emxhp -= mdam;
                                        std::cout << "You did " << mdam << "to the enemy!" << std::endl;
                                }
                        }

                        else
                        {
                                std::cout << "Please choose an option" << std::endl;
                        }

                        std::cout << "The enemy attacked!" << std::endl;                  //Showing Enemy damage
                        std::cout << "The enemy did" << edam << "to you!" << std::endl;
                        chp = mxhp -= edam;
                        system("pause");
                        system("cls");

                        if (echp <= 0)
                        {
                                std::cout << "You won!" << std::endl;  //End screen
                                std::cout << "Skills learned:" << std::endl;
                                std::cout << "None" << std::endl;
                                std::cout << "Items Obtained:" << std::endl;
                                std::cout << "Shield" << std::endl;
                                std::cout << "Stats Increased:" << std::endl;
                                std::cout << "Defense" << std::endl;
                                std::cout << "HP" << std::endl;
                                break;
                        }
                        if (chp <= 0)
                        {
                                std::cout << "You lost..." << std::endl;  //End screen
                                break;
                        }

                }

}

So I'm doing this little project for school. It is a very simple RPG. The code worked fine with one enemy, but I tried to add a second enemy to fight after the first. That's when I encountered problems. For some reason the player or enemy can't do damage. I working on Visual Studio 2015. Please help me out. Thanks in advance.

GetActiveObject() returns "Operation Unavailable" (0x800401e3) when Excel is running

$
0
0
In Windows 7, I’m trying to control Excel 2013 with OLE Automation. It works fine if Excel hasn’t already started up. I’m attempting to use GetActiveObject() to tell if it has started up, but I always get the same error: “Operation unavailable” or 0x800401e3. I get the error whether Excel is running or not. Unfortunately, if Excel is running, then the code ends up starting a new instance of Excel using CreateDispatch() which is NOT what I want to do. This is old code, and has worked with Excel for many years, although perhaps not Excel 2013.

Code:

        if( !m_XLApp.m_lpDispatch )
        {
                try
                {
                        LPDISPATCH pXLAppDispatch = NULL;
                        LPUNKNOWN lpUnk; CLSID clsid;
                        if( S_OK == ::CLSIDFromProgID(L"Excel.Application", &clsid) )
                        {
                                if( S_OK == ::GetActiveObject(clsid, NULL, &lpUnk) )  //always fails
                                {
                                        VERIFY(lpUnk->QueryInterface(IID_IDispatch, (void**)&pXLAppDispatch) == S_OK);
                                        m_XLApp.AttachDispatch( pXLAppDispatch );
                                        lpUnk->Release();
                                }
                        }
                        if( !pXLAppDispatch )
                                m_XLApp.CreateDispatch( _T("Excel.Application") );

I found a possible solution at

https://support.microsoft.com/en-us/...ce-application

but I tried the code with no success. Excel may have lost focus long before I run my program and GetActiveObject() still fails. How do I get it too succeed when Excel is running?

Thanks,
Gary

MFC code

$
0
0
Hi, ALL,
Does anybody have an old MFC source code?
I am looking for a font property page source.

I currently have MSVC 2010 Pro, but I don't see this source code unfortunately.

Thank you in advance.

Performance issue when drawing on MFC

$
0
0
Hello all & Thanks for reading this,

-I would have a question on you:
-I have created a small application on MFC/C++ that draw different geometric shapes on screen using the mouse (like Paint). These shapes can be moved and rotated,
so, I had to keep all these created shapes in a vector and draw all of them in OnDraw().
-My problem is, when I create many shapes (more than 50-60) and I try to move/rotate one of the shapes, these movements/rotations become very-very slow.
-Could you give me some tips in order to make my application faster when moving/rotating those shapes?


Code:

OnDraw(CDC* pDC)
{

    for (int i = 0; i < numberObjects; i++)
        objects[i]->DrawShape(pDC);
}


Many thanks!

Custom Save dialog

$
0
0
We have a commercial video editor written in MFC/C++. We want to do some custom stuff with the Save dialog that simply isn't possible with the new IFileDialog built in to Windows Vista+ and the old XP style dialog just doesn't look right when used in modern OSes.

Does anyone know of a 3rd party Save dialog that offers better customization while retaining the look/feel of the modern IFileDialog? Can be commercial or open source. I just don't want to have to resort to writing my own from scratch if I don't have to.

The main feature we need is the ability to filter/group the file types list after the dialog is displayed. Our product uses a user customizable profile system for saving and the list can get unwieldy. We want some way to organize or filter the list to make it easier to use, but the existing IFileDialog does not allow you to change the file types list at all after it's displayed.

If anyone knows of a dialog that will work for this purpose please let me know. Even if it's a commercial product we have to pay for it's fine.

need help with this code

$
0
0
says this when i try to run it:fatal error LNK1169: one or more multiply defined symbols found

here is the code:

Code:

#include <iostream>
using namespace std;
int main() {
        // This program calulates the unit price.
        // Written by: Joe Vardaman

        int Quantity;
        int UnitPrice;
        int TotalAmount;
        cout << "Please enter the Quantity desired";
        cin >> Quantity;
        cout << "Please enter the Unit Price:";
        cin >> UnitPrice;
        cout << "The Quantity desired is:"; cout << Quantity;
        cout << "The Unit Price is:"; cout << UnitPrice;
        TotalAmount = Quantity * UnitPrice;
        cout << " The Total amount is:"; cout << TotalAmount;
        return 0;
}

How do I create a new desktop with CreateDesktop with different wallpaper?

Why does this not work properly

$
0
0
I am new to c++ and im making this calculator but when i square or square root a number it still asks for another one how do i stop this from happening?

Code:

#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
        bool Going;
        Going = true;
        while (Going)
       
                {

                        int a;
                        int b;
                        int sum;
                        int opt;

                        string dev;

                        cout << "type in a number \n";
                        cin >> a;
                        cout << "times , add , take , divide , squareroot , square \n";
                        cin >> dev;
                        if (dev == "squareroot")
                        {
                                sum = sqrt(a);
                                cout << sum;
                        }
                        else if (dev == "square")
                        {
                                sum = a * a;
                                cout << sum;
                        }
                       
                        if (dev != "squareroot" || "square")
                        {
                                cout << "type in a number \n";
                                cin >> b;

                                if (dev == "times")
                                {
                                        sum = a * b;
                                }
                                else if (dev == "take")
                                {
                                        sum = a - b;
                                }
                                else if (dev == "add")
                                {
                                        sum = a + b;
                                }
                                else if (dev == "divide")
                                {
                                        sum = a / b;
                                }
                                cout << sum;
                        }

                        cout << "\ndo you want to continue \nyes\nno\n";
                        string NorY;
                        cin >> NorY;

                        if (NorY == "yes")
                        {
                                Going = true;
                                system("CLS");
                        }
                        else if (NorY == "no")
                        {
                                Going = false;
                        }
               
                }
        return 0;
}

How to make a window refuse/filter off some window messages?

$
0
0
when some messages coming to the window, I want to process some of the types,
but refusing specific types I don't really want to handle.
Is it possible?

This is done to a compiled executable anyways....

Thanks
Jack

Windows 10 - Size of Radio Buttons and Checkboxes

$
0
0
Hi

We have a UI where a customer have reported problem when running on Windows 10. On W10 the radio buttons and checkboxes are bigger than "normal" (compared to when they used W7), which give the result that the text is cut off. Even the caption bar is increased in size.

When we test the UI in our environment, we haven't seen this behaviour. I suppose that this must be due to some kind of setting, but haven't found out where to change.

Can anyone give me a hint of where to change / which setting.

Regards

/Lennart

Is it hard to emulate the theme service of windows 7?

$
0
0
Once the secondary shell is decoupled from the master one,
I need to write an emulated theme service.
How can I write a emulated theme service easily?
What I really want to do instead is to use the original service (I need
to duplicate it since that windows service is a single instanced service)
It is not that easy to do since when I change the theme, the cache is changed,
so subsequent call to OpenThemeData would retrieve the most recent theme.

Then I thought about giving a pass-thru hand-over call.
For example
Code:

void HookedOpenThemeData(...)
{
    // call the original service   
}

But you see, it is very difficult, when I call the original service from a hooked function,
it will always return the same theme no matter what....

And the theme service is started when the system is booted strapped.
And it is a single-instanced service.

Therefore, I must write an emulated service of that kind.....
But is it possible to create a pass-thru instead?
Thanks
Jack

Nothing happens when Control Panel App Run as admin after migrating to VS2015

$
0
0
We have one legacy Control Panel App (.cpl) that use for registry and configuration file modification. Previously it was compiled on Visual Studio 2008 and used on Server 2012 & Windows 7. We have to run as Administrator to save changes.

I have recently migrated this app to Visual Studio 2015 and when run as Administrator nothing happens (no error, nothing logged in events log)


On Windows 7:

UAC Enabled:
1) User can run application
2) Nothing happens when application run as administrator


UAC Disabled:
1) User can run application
2)User can run application as administrator


On Windows Server 2012
UAC Enabled:
1) User can run application
2) Nothing happens when application run as administrator

UAC Disabled:
1)User can run application
2)Nothing happens when application run as administrator

I have try using Windows Performance Recorder tool but I am not able to find anything about this control panel app.

Can someone point me to right direction how I can resolve this issue?

Dual monitor issue

$
0
0
I have a Windows application in Delphi 5.

I have two monitors. When my application runs, the parent is displayed on the first monitor. When I move the parent window to the second monitor and click a button, this child window stays on the first monitor. Is there a way to make the child window stay with the parent window no matter where the parent window is located? I searched related to this but solution is in C# not in Delphi, I am very new in Delphi. Child forms are creating at run time.

My Code is:

Code:

function BeforeCreateForm(Session:ISmSession;var IsDLL: Boolean):HWND;
var
  SmGUIServices: ISmGUIServices;
  MainWindowHandle:HWND;
begin
  MainWindowHandle:=0;
  IsDLL := false;
  if (Application.Handle = 0) and (Session <> nil) then
  begin
    IsDLL := true;
    SmGUIServices := (Session.Services.Item[TDM_SmarTeamServices[srvSmGUIService]] as ISmGUIServices);
    if SmGUIServices <> nil then
    {$IFNDEF BUILTPACKAGE}
      MainWindowHandle:=ForceIntegerToHwnd(SmGUIServices.MainWindowHandle);
    {$ENDIF}
  end;
  result:=MainWindowHandle;
end { of BeforeCreateForm } ;

procedure TSmForm.AfterCreateForm(Session:ISmSession; SmHelpContext:TDM_Int32; IsDLL: boolean);
begin

  if SmSession<>Session then
    SmSession:= Session;
  if SmHelpContext > 0 then
    HelpContext:=SmHelpContext;

  if (IsDLL) then
  begin
    if (Icon.Empty) and (ParentHWND <> 0) then
      SendMessage(Handle, WM_SETICON, 1, SendMessage(ParentHWND, WM_GETICON, 1, 0));
  end;
end { of TSmForm.AfterCreateForm } ;


constructor TSmForm.Create(AOwner: TComponent;Session:ISmSession;SmHelpContext:TDM_Int32);
var
  IsDLL: Boolean;
begin
  ParentHWND:=BeforeCreateForm(Session, IsDLL);
  HelpContext := 0;
  SmSession:= Session;
  inherited Create(AOwner);
  AfterCreateForm(Session,SmHelpContext, IsDLL);
end;



procedure TSmForm.CreateParams(var Params: TCreateParams);

var
  SmGuiServices: ISmGuiServices;
  MDIChild : TIMDIChildForm;
  MultiTabType :TDM_Int16;
  I:Integer;

begin
  inherited CreateParams(Params);
  if ParentHWND <> 0 then
  begin
    Params.WndParent:=ParentHWND;

    SmGUIServices := (SmSession.Services.Item[TDM_SmarTeamServices[srvSmGUIService]] as ISmGUIServices);
    for I := SmGUIServices.SmViewWindows.Count - 1 downto 0 do
    begin
      if(SmGUIServices.SmViewWindows.item[I].SmView<>nil) then 
      if(SmGUIServices.SmViewWindows.item[I].SmView.ViewType <> vwtBomView) then     
      begin                                                                           
      MDIChild := TIMDIChildForm((SmGUIServices.SmViewWindows.item[I] as ISmRawViewWindow).SmViewWindowHandle);

      MultiTabType:=GetMultiTabType( MDIChild.tabSmView, MDIChild.tabSmView.ActivePage.PageIndex);

        if UpperCase(SmSession.ApplicationName) = 'MYAPP' then
        (MDIChild.MDIViewer.ViewerType = 10))) then 

        begin

        // Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST;
          Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
        Params.WndParent := GetDesktopWindow;


          exit;
        end

        else
        begin
          if (MultiTabType = MT_Viewer) then
          begin
            Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST;
            exit;
          end;
        end;

      end;                 
    end; 
  end;
end;

How to move a process from one window to another

$
0
0
The hidden desktop is created with
HDESK hidden_desktop = CreateDesktopA(...);

I want to move the current process which contains this call to CreateDesktopA into
the hidden desktop, I can't find any good information on the web....
Thanks
Jack
Viewing all 3027 articles
Browse latest View live


Latest Images