No, it cannot be done with Disk Management.
To accomplish your goal, there are at least three steps that must be performed. (More sophisticated software may obfuscate what's going on, but under the hood any software must still follow these same steps.)
Step 1a: if necessary to accomplish step 1, compact D so no "in use" sectors are in the rear 40GB of D. *
Step 1: shrink the D partition, so you end up with C (39GB) + D (87GB) + unallocated space (40GB). **
Step 2: slide D toward the rear of the disk, so you end up with C (39GB) + unalloc (40GB) + D (87GB).
Step 3: expand C into the unallocated space, so you end up with C (79GB) + D (87GB).
Disk Management is a crippled partition manager and can only perform steps 1 and 3. It can shrink and expand, but cannot slide or compact.
However, there are several popular third-party partition managers that can perform all four tasks, as necessary. Your goal can be easily accomplished using one of those.
Footnotes:
* You need to clear the back 40GB of the D partition so its space can be deallocated. Compacting is different from defragging. Defragging pulls pieces of files together, but doesn't necessarily move all the files toward the front. Though they may now be one piece, files may still be strewn about the partition with interspersed free space.
Note a partition can only shrink to its furthest "in use" sector. You cannot deallocate space from the partition if there are still stray files in the space. Compacting rewrites those stray files more toward the front of the partition so the free space is contiguous toward the back.
** tech aside: FWIW, note the distinction between "free" space and "unallocated" space. Free space is storage space within a partition that is currently available for file storage. Unallocated space is disk space not allocated to any partition.